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

Method set_len

src/arrayvec.rs:937–954  ·  view source on GitHub ↗
(&mut self, new_len: usize)

Source from the content-addressed store, hash-verified

935 /// regarding what you find in the inactive portion of the vec.
936 #[inline(always)]
937 pub fn set_len(&mut self, new_len: usize) {
938 if new_len > A::CAPACITY {
939 // Note(Lokathor): Technically we don't have to panic here, and we could
940 // just let some other call later on trigger a panic on accident when the
941 // length is wrong. However, it's a lot easier to catch bugs when things
942 // are more "fail-fast".
943 panic!(
944 "ArrayVec::set_len> new length {} exceeds capacity {}",
945 new_len,
946 A::CAPACITY
947 )
948 }
949
950 let new_len: u16 = new_len
951 .try_into()
952 .expect("ArrayVec::set_len> new length is not in range 0..=u16::MAX");
953 self.len = new_len;
954 }
955
956 /// Splits the collection at the point given.
957 ///

Callers 8

newMethod · 0.45
try_appendMethod · 0.45
extend_from_sliceMethod · 0.45
try_fromMethod · 0.45
rand_arrvecFunction · 0.45
rand_arrvecFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected