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

Method offset

crates/vm/src/builtins/range.rs:119–128  ·  view source on GitHub ↗
(&self, value: &BigInt)

Source from the content-addressed store, hash-verified

117impl PyRange {
118 #[inline]
119 fn offset(&self, value: &BigInt) -> Option<BigInt> {
120 let start = self.start.as_bigint();
121 let stop = self.stop.as_bigint();
122 let step = self.step.as_bigint();
123 match step.sign() {
124 Sign::Plus if value >= start && value < stop => Some(value - start),
125 Sign::Minus if value <= self.start.as_bigint() && value > stop => Some(start - value),
126 _ => None,
127 }
128 }
129
130 #[inline]
131 pub fn index_of(&self, value: &BigInt) -> Option<BigInt> {

Callers 8

back_peekMethod · 0.45
next_code_pointFunction · 0.45
next_code_point_reverseFunction · 0.45
py_newMethod · 0.45
create_mmap_windowsMethod · 0.45
try_insertMethod · 0.45
index_ofMethod · 0.45
contains_innerMethod · 0.45

Calls 2

as_bigintMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected