remove usage of legacy numeric operations in script (#33095)

These operations are deprecated and might be removed
in a future rust version. Clippy is also complaining
about them.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2024-08-16 23:30:13 +02:00 committed by GitHub
parent 09cac6430b
commit f0045a7686
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 11 deletions

View file

@ -25,7 +25,7 @@ pub trait CollectionFilter: JSTraceable {
fn filter<'a>(&self, elem: &'a Element, root: &'a Node) -> bool;
}
/// An optional u32, using maxint to represent None.
/// An optional u32, using u32::MAX to represent None.
/// It would be nicer just to use Option<u32> for this, but that would produce word
/// alignment issues since Option<u32> uses 33 bits.
#[derive(Clone, Copy, JSTraceable, MallocSizeOf)]
@ -35,7 +35,7 @@ struct OptionU32 {
impl OptionU32 {
fn to_option(self) -> Option<u32> {
if self.bits == u32::max_value() {
if self.bits == u32::MAX {
None
} else {
Some(self.bits)
@ -43,14 +43,12 @@ impl OptionU32 {
}
fn some(bits: u32) -> OptionU32 {
assert_ne!(bits, u32::max_value());
assert_ne!(bits, u32::MAX);
OptionU32 { bits }
}
fn none() -> OptionU32 {
OptionU32 {
bits: u32::max_value(),
}
OptionU32 { bits: u32::MAX }
}
}