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
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X





























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