diff --git a/components/salsa-2022/src/id.rs b/components/salsa-2022/src/id.rs index 406d4a15..d168ecbe 100644 --- a/components/salsa-2022/src/id.rs +++ b/components/salsa-2022/src/id.rs @@ -38,6 +38,19 @@ impl Id { } } +impl From for Id { + fn from(n: u32) -> Self { + Id::from_u32(n) + } +} + +impl From for Id { + fn from(n: usize) -> Self { + assert!(n < Id::MAX_USIZE); + Id::from_u32(n as u32) + } +} + impl From for u32 { fn from(n: Id) -> Self { n.as_u32()