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

Method drain_range

crates/common/src/boxvec.rs:294–312  ·  view source on GitHub ↗
(&mut self, start: usize, end: usize)

Source from the content-addressed store, hash-verified

292 }
293
294 fn drain_range(&mut self, start: usize, end: usize) -> Drain<'_, T> {
295 let len = self.len();
296
297 // bounds check happens here (before length is changed!)
298 let range_slice: *const _ = &self[start..end];
299
300 // Calling `set_len` creates a fresh and thus unique mutable references, making all
301 // older aliases we created invalid. So we cannot call that function.
302 self.len = start;
303
304 unsafe {
305 Drain {
306 tail_start: end,
307 tail_len: len - end,
308 iter: (*range_slice).iter(),
309 vec: ptr::NonNull::from(self),
310 }
311 }
312 }
313
314 /// Return a slice containing all elements of the vector.
315 pub fn as_slice(&self) -> &[T] {

Callers 1

drainMethod · 0.80

Calls 2

lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected