MCPcopy Index your code
hub / github.com/RustPython/RustPython / as_u32_mask

Method as_u32_mask

crates/vm/src/builtins/int.rs:320–334  ·  view source on GitHub ↗

_PyLong_AsUnsignedLongMask

(&self)

Source from the content-addressed store, hash-verified

318
319 // _PyLong_AsUnsignedLongMask
320 pub fn as_u32_mask(&self) -> u32 {
321 let v = self.as_bigint();
322 v.to_u32()
323 .or_else(|| v.to_i32().map(|i| i as u32))
324 .unwrap_or_else(|| {
325 let mut out = 0u32;
326 for digit in v.iter_u32_digits() {
327 out = out.wrapping_shl(32) | digit;
328 }
329 match v.sign() {
330 Sign::Minus => out * -1i32 as u32,
331 _ => out,
332 }
333 })
334 }
335
336 pub fn try_to_primitive<'a, I>(&'a self, vm: &VirtualMachine) -> PyResult<I>
337 where

Callers 6

crc32Function · 0.80
crc_hqxFunction · 0.80
fcntlFunction · 0.80
adler32Function · 0.80
already_warnedFunction · 0.80
get_filterFunction · 0.80

Calls 3

as_bigintMethod · 0.80
to_u32Method · 0.45
mapMethod · 0.45

Tested by

no test coverage detected