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

Method push_unchecked

crates/common/src/boxvec.rs:88–96  ·  view source on GitHub ↗

# Safety Must ensure that self.len() < self.capacity()

(&mut self, element: T)

Source from the content-addressed store, hash-verified

86 /// # Safety
87 /// Must ensure that self.len() < self.capacity()
88 pub unsafe fn push_unchecked(&mut self, element: T) {
89 let len = self.len();
90 debug_assert!(len < self.capacity());
91 // SAFETY: len < capacity
92 unsafe {
93 ptr::write(self.get_unchecked_ptr(len), element);
94 self.set_len(len + 1);
95 }
96 }
97
98 /// Get pointer to where element at `index` would be
99 unsafe fn get_unchecked_ptr(&mut self, index: usize) -> *mut T {

Callers 1

try_pushMethod · 0.80

Calls 4

get_unchecked_ptrMethod · 0.80
set_lenMethod · 0.80
writeFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected