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

Method truncate

crates/common/src/boxvec.rs:172–180  ·  view source on GitHub ↗
(&mut self, new_len: usize)

Source from the content-addressed store, hash-verified

170 }
171
172 pub fn truncate(&mut self, new_len: usize) {
173 unsafe {
174 if new_len < self.len() {
175 let tail: *mut [_] = &mut self[new_len..];
176 self.len = new_len;
177 ptr::drop_in_place(tail);
178 }
179 }
180 }
181
182 /// Remove all elements in the vector.
183 pub fn clear(&mut self) {

Callers 4

clearMethod · 0.45
format_stringMethod · 0.45
finalize_codeMethod · 0.45
dceMethod · 0.45

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected