[go: up one dir, main page]

Today I Learned

tags


2023/03/04

The string “0.1.12” is a version requirement. Although it looks like a specific version of the time crate, it actually specifies a range of versions and allows SemVer compatible updates.

https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html

Instead, in order to lock to a specific version of a crate, you need to write = 0.1.2.


2024/04/27

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.


2024/06/23

That a cargo package can have only one library: see https://doc.rust-lang.org/cargo/reference/cargo-targets.html#library.