VS Code with Rust?

I'm a beginner in Rust.

I've created a new file coden.rs. I want to run it. I'm using VSCode.

I type cargo run in the terminal. Now the main.rs file is executed, but not coden.rs. Why?

Can someone please help me here.

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
2 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
jo135
1 year ago

Cargo assumes that a Binary Crate (i.e. a project containing an executable program) has the main function in src/main.rs. This is exactly what is being done.

If you want to have and select several, you should put them in src/bin/.

VS Code doesn’t have anything to do, it doesn’t matter which editor you use.