MCPcopy Create free account
hub / github.com/Lokathor/tinyvec / try_push

Method try_push

src/arrayvec.rs:713–724  ·  view source on GitHub ↗
(&mut self, val: A::Item)

Source from the content-addressed store, hash-verified

711 /// ```
712 #[inline(always)]
713 pub fn try_push(&mut self, val: A::Item) -> Option<A::Item> {
714 debug_assert!(self.len as usize <= A::CAPACITY);
715
716 let itemref = match self.data.as_slice_mut().get_mut(self.len as usize) {
717 None => return Some(val),
718 Some(x) => x,
719 };
720
721 *itemref = val;
722 self.len += 1;
723 return None;
724 }
725
726 /// Removes the item at `index`, shifting all others down by one index.
727 ///

Callers 2

pushMethod · 0.80
pushMethod · 0.80

Calls 1

as_slice_mutMethod · 0.45

Tested by

no test coverage detected