From bc01b9b0d1264653b6d5db325501d4d90d13c925 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 18 Aug 2022 06:48:57 -0400 Subject: [PATCH] make Id::from_u32 public I made it private, but it turns out that dada uses it, and it seems reasnable. --- components/salsa-2022/src/id.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/salsa-2022/src/id.rs b/components/salsa-2022/src/id.rs index 2a8294c..406d4a1 100644 --- a/components/salsa-2022/src/id.rs +++ b/components/salsa-2022/src/id.rs @@ -19,8 +19,14 @@ impl Id { pub const MAX_U32: u32 = std::u32::MAX - 0xFF; pub const MAX_USIZE: usize = Self::MAX_U32 as usize; + /// Create a `salsa::Id` from a u32 value. This value should + /// be less than [`Self::MAX_U32`]. + /// + /// In general, you should not need to create salsa ids yourself, + /// but it can be useful if you are using the type as a general + /// purpose "identifier" internally. #[track_caller] - pub(crate) fn from_u32(x: u32) -> Self { + pub fn from_u32(x: u32) -> Self { assert!(x < Self::MAX_U32); Id { value: NonZeroU32::new(x + 1).unwrap(),