mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-15 01:39:25 +00:00
Merge #356
356: make Id::from_u32 public r=nikomatsakis a=nikomatsakis I made it private 'just because', but it turns out that dada uses it, and it seems reasonable. Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
This commit is contained in:
commit
5aebeeb9e5
1 changed files with 7 additions and 1 deletions
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue