MCPcopy Create free account
hub / github.com/RustPython/RustPython / rotate

Method rotate

crates/vm/src/stdlib/_collections.rs:263–274  ·  view source on GitHub ↗
(&self, mid: OptionalArg<isize>)

Source from the content-addressed store, hash-verified

261
262 #[pymethod]
263 fn rotate(&self, mid: OptionalArg<isize>) {
264 self.state.fetch_add(1);
265 let mut deque = self.borrow_deque_mut();
266 if !deque.is_empty() {
267 let mid = mid.unwrap_or(1) % deque.len() as isize;
268 if mid.is_negative() {
269 deque.rotate_left(-mid as usize);
270 } else {
271 deque.rotate_right(mid as usize);
272 }
273 }
274 }
275
276 #[pygetset]
277 const fn maxlen(&self) -> Option<usize> {

Callers

nothing calls this directly

Calls 3

borrow_deque_mutMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected