What is the idiomatic way to manage a project with multiple crates?

I think that there are two popular conventions.

All crates live in the same directory and depend on each other via path = "../other-crate/".

lib-foo/
    Cargo.toml
    src/

lib-bar/
    Cargo.toml
    src/

lib-main/
    Cargo.toml
    src/

Example: https://github.com/nikomatsakis/lalrpop

Another convention is that there is one main crate, which have dependencies of the form { path = ./other-crate}

Cargo.toml
src/

lib-bar/
    Cargo.toml
    src/

lib-foo/
    Cargo.toml
    src/

Example: https://github.com/google/xi-editor/tree/master/rust

as a variation, sub crates might live in the special directory (my personal preference):

Cargo.toml
src/

lib/
    bar/
        Cargo.toml
        src/

    foo/
        Cargo.toml
        src/
3 Likes