We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
set_len()
1 parent 76aa8a8 commit ddc3736Copy full SHA for ddc3736
1 file changed
rust/kernel/alloc/kvec.rs
@@ -192,6 +192,19 @@ where
192
self.len
193
}
194
195
+ /// Forcefully sets `self.len` to `new_len`.
196
+ ///
197
+ /// # Safety
198
199
+ /// - `new_len` must be less than or equal to [`Self::capacity`].
200
+ /// - If `new_len` is greater than `self.len`, all elements within the interval
201
+ /// [`self.len`,`new_len`) must be initialized.
202
+ #[inline]
203
+ pub unsafe fn set_len(&mut self, new_len: usize) {
204
+ debug_assert!(new_len <= self.capacity());
205
+ self.len = new_len;
206
+ }
207
+
208
/// Increments `self.len` by `additional`.
209
///
210
/// # Safety
0 commit comments