about summary refs log tree commit diff
path: root/library/alloc/src/vec.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2020-07-21 23:06:23 +0200
committerSimon Sapin <simon.sapin@exyr.org>2020-07-29 10:53:55 +0200
commitd8bcf75206e88e07cabd95b87418fe98c5fa2b95 (patch)
tree33b8ab569d37c7faf64843d7bbc0069d43a24712 /library/alloc/src/vec.rs
parent10c375700ce170fc57cb617754dc6d0631d3d573 (diff)
downloadrust-d8bcf75206e88e07cabd95b87418fe98c5fa2b95.tar.gz
rust-d8bcf75206e88e07cabd95b87418fe98c5fa2b95.zip
Make `Vec::leak` a method instead of an associated function.
The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T`
which might have its own, different `leak` method) does not apply.
Diffstat (limited to 'library/alloc/src/vec.rs')
-rw-r--r--library/alloc/src/vec.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs
index f5a3d0cd4af..3414060a556 100644
--- a/library/alloc/src/vec.rs
+++ b/library/alloc/src/vec.rs
@@ -1513,17 +1513,17 @@ impl<T> Vec<T> {
     /// #![feature(vec_leak)]
     ///
     /// let x = vec![1, 2, 3];
-    /// let static_ref: &'static mut [usize] = Vec::leak(x);
+    /// let static_ref: &'static mut [usize] = x.leak();
     /// static_ref[0] += 1;
     /// assert_eq!(static_ref, &[2, 2, 3]);
     /// ```
     #[unstable(feature = "vec_leak", issue = "62195")]
     #[inline]
-    pub fn leak<'a>(vec: Vec<T>) -> &'a mut [T]
+    pub fn leak<'a>(self) -> &'a mut [T]
     where
         T: 'a, // Technically not needed, but kept to be explicit.
     {
-        Box::leak(vec.into_boxed_slice())
+        Box::leak(self.into_boxed_slice())
     }
 }