We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Vec::leak
1 parent 10c3757 commit d8bcf75Copy full SHA for d8bcf75
library/alloc/src/vec.rs
@@ -1513,17 +1513,17 @@ impl<T> Vec<T> {
1513
/// #![feature(vec_leak)]
1514
///
1515
/// let x = vec![1, 2, 3];
1516
- /// let static_ref: &'static mut [usize] = Vec::leak(x);
+ /// let static_ref: &'static mut [usize] = x.leak();
1517
/// static_ref[0] += 1;
1518
/// assert_eq!(static_ref, &[2, 2, 3]);
1519
/// ```
1520
#[unstable(feature = "vec_leak", issue = "62195")]
1521
#[inline]
1522
- pub fn leak<'a>(vec: Vec<T>) -> &'a mut [T]
+ pub fn leak<'a>(self) -> &'a mut [T]
1523
where
1524
T: 'a, // Technically not needed, but kept to be explicit.
1525
{
1526
- Box::leak(vec.into_boxed_slice())
+ Box::leak(self.into_boxed_slice())
1527
}
1528
1529
0 commit comments