Fix: error: mismatched closing delimiter } [Rust]


fn main() {
    println!("Hello, world!";
}

If you try to do a cargo build for the above code, you will get a mismatched closing delimiter error.

Error:
% cargo build
   Compiling myproj1 v0.1.0 (/Users/c2ctechtv/Desktop/myproj1)
error: mismatched closing delimiter: `}`
 --> src/main.rs:2:13
  |
1 | fn main() {
  |           - closing delimiter possibly meant for this
2 |     println!("Hello, world!";
  |             ^ unclosed delimiter
3 | }
  | ^ mismatched closing delimiter

error: could not compile `myproj1` (bin "myproj1") due to previous error

You may wonder that the error says missing "curly brace }" but it is actually the closing brace ) at line 2.

Closing Braces missing

After adding it the build goes well!

% cargo build
   Compiling myproj1 v0.1.0 (/Users/c2ctech/Desktop/myproj1)
    Finished dev [unoptimized + debuginfo] target(s) in 0.66s
Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org










Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap