Today I Learned

2024/04/27

cargo workspaces

That you can add a [workspace.dependencies] table in your top-level Cargo.toml specifying paths to internal crates:

# ${PROJECT_DIR}/Cargo.toml
[workspace]
members = ["path/to/my_crate"]

[workspace.dependencies]
my_crate = { path = "path/to/my_crate" }
# ${PROJECT_DIR}/path/to/other_crate/Cargo.toml
[dependencies]
my_crate = { workspace = true}

See https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table. See also https://doc.rust-lang.org/cargo/reference/workspaces.html.

workspace = true can also help share external dependencies within multiple internal crates; see https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace.


Also, that u32 and u64 don’t implement Into<usize>! I guess rust supports 16-bit pointer sizes.