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 88d5d6a commit a1e4d5cCopy full SHA for a1e4d5c
rust/kernel/alloc/kvec.rs
@@ -413,6 +413,26 @@ where
413
(ptr, len, capacity)
414
}
415
416
+ /// Clears the vector, removing all values.
417
+ ///
418
+ /// Note that this method has no effect on the allocated capacity
419
+ /// of the vector.
420
421
+ /// # Examples
422
423
+ /// ```
424
+ /// let mut v = kernel::kvec![1, 2, 3]?;
425
426
+ /// v.clear();
427
428
+ /// assert!(v.is_empty());
429
+ /// # Ok::<(), Error>(())
430
431
+ #[inline]
432
+ pub fn clear(&mut self) {
433
+ self.truncate(0);
434
+ }
435
+
436
/// Ensures that the capacity exceeds the length by at least `additional` elements.
437
///
438
/// # Examples
0 commit comments