What is the reason behind lib.rs sometimes and main.rs sometimes?

So I was following a tutorial and instead of a main.rs which is by default created when we do

cargo new someproject

However when I ran

cargo check

It says lib.rs not found so I have to rename and use some macros. Is there something specific I should be reading?

src/main.rs is the default path for binary crate (i.e. executable program), src/lib.rs is the default path for the library crate (i.e it can be used as dependency by other packages). see:

there's something else wrong here, cargo check works both for binary crates and library crates. do you mind show more details of your code?

1 Like

that was super helful mate thanks