path = "src/core/vec3.rs"
It looks like you are thinking that
lib.path is used to include files as part of the library compilation. That is not the case. Since you mention C++ experience, I'll contrast with that:
rustc, a single compiler invocation (compiling a single “crate” into a single library or binary) is not given multiple source files (like C compilers accept), but one source file, the “crate root”. That crate root file then effectively includes all other source files, nearly always by means of
mod (which improves on C
#include by always creating a new module/namespace).
The first step to fixing your problem is to remove
Cargo.tomls do not need
path at all, because they have a file layout which follows Cargo target auto-discovery.) That will cause the compiler to stop reading
src/core/vec3.rs and to start reading
src/lib.rs (which it is currently ignoring, because it's been told to).
Once you do that, you will see an error like "file not found for
core". This is because every
mod item has a corresponding file (or inline body) even if its purpose is to contain other modules. Think of modules like functions: functions always have code in them, even if their only job is to call another function. To resolve this error, create a
src/core.rs (child modules of the crate root go next to the crate root), with the contents
pub mod vec3;
This is how you tell the compiler that the path
core::vec3 should exist, and how you tell the compiler to read the file
src/core/vec3.rs. With these two changes, your original
src/lib.rs source should now compile successfully, and hopefully so will
Another thing that is not necessary, but I recommend you do to reduce confusion, is to rename your
core is also the name of one of the Rust standard library crates. It is not necessarily a problem but you (or a future reader or maintainer) might end up with a confusing error at some point.
By the way, thanks for including a detailed file listing and contents — the usual problem with helping people learn how to lay out a Rust project is not having all that information. The one thing that would have been good to also include is the full error message from the compiler, with all of its report of the involved file(s) and hints about what to do.
Let us know how it goes after my suggestions! We'll be happy to advise you more on good, as well as working, layout once there's more to see.