MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / mut_vec

Method mut_vec

src/fast.rs:114–120  ·  view source on GitHub ↗

Accesses the [`FastVec`] mutably as a [`Vec`]. # Safety If `f` panics the [`Vec`] must be unmodified.

(&mut self, f: impl FnOnce(&mut Vec<T>))

Source from the content-addressed store, hash-verified

112 /// # Safety
113 /// If `f` panics the [`Vec`] must be unmodified.
114 unsafe fn mut_vec(&mut self, f: impl FnOnce(&mut Vec<T>)) {
115 let copied = std::ptr::read(self as *mut FastVec<T>);
116 let mut vec = ManuallyDrop::new(Vec::from(copied));
117 f(&mut vec);
118 let copied = FastVec::from(ManuallyDrop::into_inner(vec));
119 std::ptr::write(self as *mut FastVec<T>, copied);
120 }
121
122 /// Get a pointer to write to without incrementing length.
123 #[inline(always)]

Callers 1

reserve_slowMethod · 0.80

Calls 1

fFunction · 0.85

Tested by

no test coverage detected