I'm currently following the rust book, but I'm having difficulty in the crates part, for example, in the minigrep project, I create a new project "cargo new minigrep", then I enter the project "cd minigrep", my problem is right now to create a library, I create one inside the project "cargo new Library --lib" but then I can't import it to my project that contains main, inside it I have an object called "Config", the book says to use it just in the main module put "use minigrep::Config;" but it doesn't work, could someone help me? sorry for the rubbish and mistakes, english is not my native language.
You have created a separate package inside your minigrep package.
Not to worry though, there is an easy fix.
Delete the Library folder.
Make a library which is part of the minigrep project.
All you need is a file named
main.rsin the same directory.
lib.rs will contain your
Hope that helps!
If you're curious why:
A cargo.toml is associated with a package, which is why it has [package] at the top. A package can have 0-1 library and 0-n binary crates, minimum 1.
main.rs are separate crates!
lib.rs contains your library crate and
main.rs is your (main) binary crate.
cargo new creates a package.
I think there are easier to understand sources for this information, but I can't find them right now!
thanks dude <3