From 1c9c7280b796af9a62d89d517e1e7e9c7f2160e4 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 18 Aug 2022 16:35:50 -0400 Subject: [PATCH] add from impls for u32/usize --- components/salsa-2022/src/id.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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()