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

Method try_push

crates/common/src/boxvec.rs:75–84  ·  view source on GitHub ↗
(&mut self, element: T)

Source from the content-addressed store, hash-verified

73 }
74
75 pub fn try_push(&mut self, element: T) -> Result<(), CapacityError<T>> {
76 if self.len() < self.capacity() {
77 unsafe {
78 self.push_unchecked(element);
79 }
80 Ok(())
81 } else {
82 Err(CapacityError::new(element))
83 }
84 }
85
86 /// # Safety
87 /// Must ensure that self.len() < self.capacity()

Callers 1

pushMethod · 0.80

Calls 5

newFunction · 0.85
push_uncheckedMethod · 0.80
ErrClass · 0.50
lenMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected