Skip to content

Commit

Permalink
Constify objectid constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
morr0ne committed Feb 11, 2025
1 parent 552fc40 commit 66e1ec9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/wire/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ impl ObjectId {
Self(NonZeroU32::new_unchecked(id))
}

pub fn new(id: u32) -> Option<Self> {
NonZeroU32::new(id).map(Self)
pub const fn new(id: u32) -> Option<Self> {
if id == 0 {
return None;
}

Some(unsafe { Self::from_raw(id) })
}
}

Expand Down

0 comments on commit 66e1ec9

Please sign in to comment.