Problem
platform-trees (and potentially other crates that depend on platform-num) currently need to declare num-traits as a direct dependency even though platform-num already depends on it internally. This is because Rust/Cargo requires explicit direct dependencies — transitive dependencies are not accessible in code.
As a result, platform-trees has:
[dependencies]
num-traits = "0.2.19" # required for Unsigned, FromPrimitive
platform-num = "0.5.0" # also internally uses num-traits
This creates a version drift risk: if platform-num upgrades its internal num-traits version (e.g., to 0.3.x) while a dependent still uses 0.2.x, the trait bounds (Unsigned, FromPrimitive) become incompatible types and compilation fails.
Reproducible Example
// Works today, but fragile:
use num_traits::{FromPrimitive, Unsigned}; // from direct dep
use platform_num::Number; // from platform-num dep
pub trait LinkType: Number + Unsigned + TryFrom<u8> + FromPrimitive {}
If num-traits versions diverge, Unsigned from one version is not the same type as Unsigned from another, causing a compile error.
Proposed Solution
Add re-exports of the num-traits traits that platform-num already uses internally:
// In platform-num's src/lib.rs
pub use num_traits::{AsPrimitive, FromPrimitive, PrimInt, Signed, ToPrimitive, Unsigned};
This would allow dependents to write:
use platform_num::{Number, FromPrimitive, Unsigned};
// No separate num-traits dependency needed!
And their Cargo.toml could drop the direct num-traits dep entirely:
[dependencies]
platform-num = "0.5.0" # includes all needed num-traits re-exports
Benefits
- Version consistency guaranteed: Dependent crates always use the exact same
num-traits version as platform-num
- Simpler dependency management for crates in the linksplatform ecosystem
- Single source of truth: Only
platform-num needs to track the num-traits version
Workaround
Until this is implemented, dependents should pin their num-traits version to match platform-num's exact version:
num-traits = "0.2.19" # matches platform-num 0.5.0's pinned version
Related
Problem
platform-trees(and potentially other crates that depend onplatform-num) currently need to declarenum-traitsas a direct dependency even thoughplatform-numalready depends on it internally. This is because Rust/Cargo requires explicit direct dependencies — transitive dependencies are not accessible in code.As a result,
platform-treeshas:This creates a version drift risk: if
platform-numupgrades its internalnum-traitsversion (e.g., to0.3.x) while a dependent still uses0.2.x, the trait bounds (Unsigned,FromPrimitive) become incompatible types and compilation fails.Reproducible Example
If
num-traitsversions diverge,Unsignedfrom one version is not the same type asUnsignedfrom another, causing a compile error.Proposed Solution
Add re-exports of the
num-traitstraits thatplatform-numalready uses internally:This would allow dependents to write:
And their
Cargo.tomlcould drop the directnum-traitsdep entirely:Benefits
num-traitsversion asplatform-numplatform-numneeds to track thenum-traitsversionWorkaround
Until this is implemented, dependents should pin their
num-traitsversion to matchplatform-num's exact version:Related