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