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