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

Method saturate

crates/vm/src/sequence.rs:156–164  ·  view source on GitHub ↗
(self, len: usize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

154
155impl OptionalRangeArgs {
156 pub fn saturate(self, len: usize, vm: &VirtualMachine) -> PyResult<(usize, usize)> {
157 let saturate = |obj: PyObjectRef| -> PyResult<_> {
158 obj.try_into_value(vm)
159 .map(|int: PyIntRef| int.as_bigint().saturated_at(len))
160 };
161 let start = self.start.map_or(Ok(0), saturate)?;
162 let stop = self.stop.map_or(Ok(len), saturate)?;
163 Ok((start, stop))
164 }
165}

Callers 4

indexMethod · 0.80
indexMethod · 0.80
indexMethod · 0.80
indexMethod · 0.80

Calls 4

try_into_valueMethod · 0.80
saturated_atMethod · 0.80
as_bigintMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected