We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a2d9f7 commit bf3ab36Copy full SHA for bf3ab36
rust/kernel/alloc/kvec.rs
@@ -416,6 +416,26 @@ where
416
(ptr, len, capacity)
417
}
418
419
+ /// Clears the vector, removing all values.
420
+ ///
421
+ /// Note that this method has no effect on the allocated capacity
422
+ /// of the vector.
423
424
+ /// # Examples
425
426
+ /// ```
427
+ /// let mut v = kernel::kvec![1, 2, 3]?;
428
429
+ /// v.clear();
430
431
+ /// assert!(v.is_empty());
432
+ /// # Ok::<(), Error>(())
433
434
+ #[inline]
435
+ pub fn clear(&mut self) {
436
+ self.truncate(0);
437
+ }
438
+
439
/// Ensures that the capacity exceeds the length by at least `additional` elements.
440
///
441
/// # Examples
0 commit comments