]> git.lizzy.rs Git - rust.git/commitdiff
Stabilize clone
authorAaron Turon <aturon@mozilla.com>
Sat, 20 Dec 2014 08:35:06 +0000 (00:35 -0800)
committerAaron Turon <aturon@mozilla.com>
Sat, 20 Dec 2014 08:37:44 +0000 (00:37 -0800)
This patch marks `clone` stable, as well as the `Clone` trait, but
leaves `clone_from` unstable. The latter will be decided by the beta.

The patch also marks most manual implementations of `Clone` as stable,
except where the APIs are otherwise deprecated or where there is
uncertainty about providing `Clone`.

20 files changed:
src/liballoc/arc.rs
src/liballoc/boxed.rs
src/liballoc/rc.rs
src/libcollections/bit.rs
src/libcollections/btree/node.rs
src/libcollections/dlist.rs
src/libcollections/ring_buf.rs
src/libcollections/vec.rs
src/libcore/array.rs
src/libcore/borrow.rs
src/libcore/cell.rs
src/libcore/clone.rs
src/libcore/hash/sip.rs
src/libcore/iter.rs
src/libcore/option.rs
src/libcore/ptr.rs
src/libcore/slice.rs
src/libcore/tuple/mod.rs
src/libstd/comm/mod.rs
src/libstd/io/comm_adapters.rs

index e909947ab08b0cb9e55d9915803c3fdf26503119..c3bd5c4157c8906a8e0598c96c75269e4799381d 100644 (file)
@@ -132,7 +132,7 @@ pub fn weak_count<T>(this: &Arc<T>) -> uint { this.inner().weak.load(atomic::Seq
 #[experimental]
 pub fn strong_count<T>(this: &Arc<T>) -> uint { this.inner().strong.load(atomic::SeqCst) }
 
-#[unstable = "waiting on stability of Clone"]
+#[stable]
 impl<T> Clone for Arc<T> {
     /// Duplicate an atomically reference counted wrapper.
     ///
index 879a8cc6951a133063fcb91afe0ae22526144fc7..f0c96196b78fc1d4fb8646cfc35c86a4beb3156b 100644 (file)
@@ -57,7 +57,7 @@ impl<T> Default for Box<[T]> {
     fn default() -> Box<[T]> { box [] }
 }
 
-#[unstable]
+#[stable]
 impl<T: Clone> Clone for Box<T> {
     /// Returns a copy of the owned box.
     #[inline]
index 0257c640d3ccd58599927f2336a925c4cd815dab..b22c366e29dc10a07ecfcb4c148df1c079645640 100644 (file)
@@ -413,7 +413,7 @@ fn drop(&mut self) {
     }
 }
 
-#[unstable = "Clone is unstable."]
+#[stable]
 impl<T> Clone for Rc<T> {
     /// Makes a clone of the `Rc<T>`.
     ///
index 7f78d56607e7ae9503983fe9e515e37f458d0859..2025af1286bb36bc5d135e7129e1f47dd8b1551d 100644 (file)
@@ -851,6 +851,7 @@ fn extend<I: Iterator<bool>>(&mut self, mut iterator: I) {
     }
 }
 
+#[stable]
 impl Clone for Bitv {
     #[inline]
     fn clone(&self) -> Bitv {
index 9698b06c7fa0f266c7bd52f89e11d0c541959470..56b544c4087c6acf8e4d631e7dc57c33b9e00a02 100644 (file)
@@ -390,6 +390,7 @@ pub fn edges_mut<'a>(&'a mut self) -> &'a mut [Node<K, V>] {
 }
 
 // FIXME(gereeter) Write an efficient clone_from
+#[stable]
 impl<K: Clone, V: Clone> Clone for Node<K, V> {
     fn clone(&self) -> Node<K, V> {
         let mut ret = if self.is_leaf() {
index e7454aef51e8e9aac9d7f00478d40b0a26769040..04bd40bf51adea353812c05b5efad0134a76ed6a 100644 (file)
@@ -758,6 +758,7 @@ fn cmp(&self, other: &DList<A>) -> Ordering {
     }
 }
 
+#[stable]
 impl<A: Clone> Clone for DList<A> {
     fn clone(&self) -> DList<A> {
         self.iter().map(|x| x.clone()).collect()
index cdb92d302e9d31ed880c3a21cee4fae0090baa9a..5d53520b8f34732f6ad14ba769921f7f87f42229 100644 (file)
@@ -48,6 +48,7 @@ pub struct RingBuf<T> {
     ptr: *mut T
 }
 
+#[stable]
 impl<T: Clone> Clone for RingBuf<T> {
     fn clone(&self) -> RingBuf<T> {
         self.iter().map(|t| t.clone()).collect()
index e986b2044306f058291a07cb37d1aa01342a9743..7fca8b377053d8720126e20e22fc6aaf3709ee4f 100644 (file)
@@ -443,7 +443,7 @@ pub fn partitioned<F>(&self, mut f: F) -> (Vec<T>, Vec<T>) where F: FnMut(&T) ->
     }
 }
 
-#[unstable]
+#[stable]
 impl<T:Clone> Clone for Vec<T> {
     fn clone(&self) -> Vec<T> { self.as_slice().to_vec() }
 
index ffaf35414ea0c41d0b3453510b8641da8fee479e..e85a132ed363f5a2e6c85dceef701117913118ef 100644 (file)
@@ -25,7 +25,7 @@
 macro_rules! array_impls {
     ($($N:expr)+) => {
         $(
-            #[unstable = "waiting for Clone to stabilize"]
+            #[stable]
             impl<T:Copy> Clone for [T, ..$N] {
                 fn clone(&self) -> [T, ..$N] {
                     *self
@@ -115,4 +115,3 @@ fn cmp(&self, other: &[T, ..$N]) -> Ordering {
     20 21 22 23 24 25 26 27 28 29
     30 31 32
 }
-
index b44b87bd938075cc169a57c652a34c8aafc1dd43..9bbcf67773ebbc966bc9081ea1bde77e0dbf34de 100644 (file)
@@ -137,6 +137,7 @@ pub enum Cow<'a, T, Sized? B: 'a> where B: ToOwned<T> {
     Owned(T)
 }
 
+#[stable]
 impl<'a, T, Sized? B> Clone for Cow<'a, T, B> where B: ToOwned<T> {
     fn clone(&self) -> Cow<'a, T, B> {
         match *self {
index 01979e975774c4b491b708b1d8017f843aabc4d4..e0041f9738eca9b147e83bc84b94a245ae042fde 100644 (file)
@@ -208,7 +208,7 @@ pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> {
     }
 }
 
-#[unstable = "waiting for `Clone` trait to become stable"]
+#[stable]
 impl<T:Copy> Clone for Cell<T> {
     fn clone(&self) -> Cell<T> {
         Cell::new(self.get())
@@ -341,7 +341,7 @@ pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> {
     }
 }
 
-#[unstable = "waiting for `Clone` to become stable"]
+#[stable]
 impl<T: Clone> Clone for RefCell<T> {
     fn clone(&self) -> RefCell<T> {
         RefCell::new(self.borrow().clone())
index f6be422813ac592ba0e5be56939a8beac7cf8c79..686ccf6f1a2513c25e2c7dfd5aa2265d11b90ccb 100644 (file)
 //! explicitly, by convention implementing the `Clone` trait and calling
 //! the `clone` method.
 
-#![unstable]
+#![stable]
 
 use kinds::Sized;
 
 /// A common trait for cloning an object.
+#[stable]
 pub trait Clone {
     /// Returns a copy of the value.
+    #[stable]
     fn clone(&self) -> Self;
 
     /// Perform copy-assignment from `source`.
@@ -34,12 +36,13 @@ pub trait Clone {
     /// but can be overridden to reuse the resources of `a` to avoid unnecessary
     /// allocations.
     #[inline(always)]
-    #[experimental = "this function is mostly unused"]
+    #[unstable = "this function rarely unused"]
     fn clone_from(&mut self, source: &Self) {
         *self = source.clone()
     }
 }
 
+#[stable]
 impl<'a, Sized? T> Clone for &'a T {
     /// Return a shallow copy of the reference.
     #[inline]
@@ -48,6 +51,7 @@ fn clone(&self) -> &'a T { *self }
 
 macro_rules! clone_impl {
     ($t:ty) => {
+        #[stable]
         impl Clone for $t {
             /// Return a deep copy of the value.
             #[inline]
@@ -95,4 +99,3 @@ fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
 extern_fn_clone! { A, B, C, D, E, F }
 extern_fn_clone! { A, B, C, D, E, F, G }
 extern_fn_clone! { A, B, C, D, E, F, G, H }
-
index e10f5a9fed1888ba02b00d26ec92335ea1ff49e2..628c1897f6e72176c0326817db18bc1c52bcd21e 100644 (file)
@@ -195,6 +195,7 @@ fn write(&mut self, msg: &[u8]) {
     }
 }
 
+#[stable]
 impl Clone for SipState {
     #[inline]
     fn clone(&self) -> SipState {
index 1f83aad9c7cdca21768788d3bbf9a6e02c7938d3..b592d1db274f63ec9b5dc37a7c2d2056250ae426 100644 (file)
@@ -1386,6 +1386,7 @@ pub struct Map<A, B, I: Iterator<A>, F: FnMut(A) -> B> {
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, B, I, F> Clone for Map<A, B, I, F> where
     I: Clone + Iterator<A>,
     F: Clone + FnMut(A) -> B,
@@ -1460,6 +1461,7 @@ pub struct Filter<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, I, P> Clone for Filter<A, I, P> where
     I: Clone + Iterator<A>,
     P: Clone + FnMut(&A) -> bool,
@@ -1518,6 +1520,7 @@ pub struct FilterMap<A, B, I, F> where I: Iterator<A>, F: FnMut(A) -> Option<B>
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, B, I, F> Clone for FilterMap<A, B, I, F> where
     I: Clone + Iterator<A>,
     F: Clone + FnMut(A) -> Option<B>,
@@ -1693,6 +1696,7 @@ pub struct SkipWhile<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, I, P> Clone for SkipWhile<A, I, P> where
     I: Clone + Iterator<A>,
     P: Clone + FnMut(&A) -> bool,
@@ -1736,6 +1740,7 @@ pub struct TakeWhile<A, I, P> where I: Iterator<A>, P: FnMut(&A) -> bool {
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, I, P> Clone for TakeWhile<A, I, P> where
     I: Clone + Iterator<A>,
     P: Clone + FnMut(&A) -> bool,
@@ -1911,6 +1916,7 @@ pub struct Scan<A, B, I, St, F> where I: Iterator<A>, F: FnMut(&mut St, A) -> Op
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, B, I, St, F> Clone for Scan<A, B, I, St, F> where
     I: Clone + Iterator<A>,
     St: Clone,
@@ -1955,6 +1961,7 @@ pub struct FlatMap<A, B, I, U, F> where I: Iterator<A>, U: Iterator<B>, F: FnMut
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, B, I, U, F> Clone for FlatMap<A, B, I, U, F> where
     I: Clone + Iterator<A>,
     U: Clone + Iterator<B>,
@@ -2115,6 +2122,7 @@ pub struct Inspect<A, I, F> where I: Iterator<A>, F: FnMut(&A) {
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, I, F> Clone for Inspect<A, I, F> where
     I: Clone + Iterator<A>,
     F: Clone + FnMut(&A),
@@ -2222,6 +2230,7 @@ pub struct Unfold<A, St, F> where F: FnMut(&mut St) -> Option<A> {
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<A, St, F> Clone for Unfold<A, St, F> where
     F: Clone + FnMut(&mut St) -> Option<A>,
     St: Clone,
index 314b47fc6476becb56a2a59cf473988def0cad10..8adbba8b94b87492f3d16cded48167159bda36b0 100644 (file)
@@ -819,6 +819,7 @@ fn next_back(&mut self) -> Option<&'a A> { self.inner.next_back() }
 
 impl<'a, A> ExactSizeIterator<&'a A> for Iter<'a, A> {}
 
+#[stable]
 impl<'a, A> Clone for Iter<'a, A> {
     fn clone(&self) -> Iter<'a, A> {
         Iter { inner: self.inner.clone() }
index 36c6b9572ea7011558a9f6c2e1aba5ecf4b1eafe..1726a7537927974d8277df75b69ebc89185f2eb7 100644 (file)
@@ -340,6 +340,7 @@ fn equiv(&self, other: &*const T) -> bool {
     }
 }
 
+#[stable]
 impl<T> Clone for *const T {
     #[inline]
     fn clone(&self) -> *const T {
@@ -347,6 +348,7 @@ fn clone(&self) -> *const T {
     }
 }
 
+#[stable]
 impl<T> Clone for *mut T {
     #[inline]
     fn clone(&self) -> *mut T {
@@ -451,4 +453,3 @@ fn gt(&self, other: &*mut T) -> bool { *self > *other }
     #[inline]
     fn ge(&self, other: &*mut T) -> bool { *self >= *other }
 }
-
index f5d117bca9fc8f45fd250b5cf4113f090e45e6c1..efc92429afdf1e5f7b0717b70f37de03b5cdbfa2 100644 (file)
@@ -781,7 +781,7 @@ impl<'a,T> Copy for Items<'a,T> {}
 #[experimental = "needs review"]
 impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}
 
-#[experimental = "needs review"]
+#[stable]
 impl<'a, T> Clone for Items<'a, T> {
     fn clone(&self) -> Items<'a, T> { *self }
 }
@@ -893,6 +893,7 @@ pub struct Splits<'a, T:'a, P> where P: FnMut(&T) -> bool {
 }
 
 // FIXME(#19839) Remove in favor of `#[deriving(Clone)]`
+#[stable]
 impl<'a, T, P> Clone for Splits<'a, T, P> where P: Clone + FnMut(&T) -> bool {
     fn clone(&self) -> Splits<'a, T, P> {
         Splits {
@@ -1550,4 +1551,3 @@ macro_rules! impl_int_slice {
 impl_int_slice! { u32,  i32 }
 impl_int_slice! { u64,  i64 }
 impl_int_slice! { uint, int }
-
index 5ea84f7db9179bb440bc88dbcdf7bb60ad282f63..1a82109be5bcf1eefbfaf9964e13bb92666a308b 100644 (file)
@@ -126,7 +126,7 @@ fn $mutN<'a>(&'a mut self) -> &'a mut $T {
                 )+
             }
 
-            #[unstable = "waiting for Clone to stabilize"]
+            #[stable]
             impl<$($T:Clone),+> Clone for ($($T,)+) {
                 fn clone(&self) -> ($($T,)+) {
                     ($(e!(self.$idx.clone()),)+)
@@ -328,4 +328,3 @@ macro_rules! lexical_cmp {
         (val11, ref11, mut11, 11) -> L
     }
 }
-
index 9043cb8c7d6f5f6b40632d10e27b0716a81fe4e7..55f5662dbd897274b489c897fe19289342736643 100644 (file)
@@ -628,7 +628,7 @@ pub fn send_opt(&self, t: T) -> Result<(), T> {
     }
 }
 
-#[unstable]
+#[stable]
 impl<T: Send> Clone for Sender<T> {
     fn clone(&self) -> Sender<T> {
         let (packet, sleeper, guard) = match *unsafe { self.inner() } {
@@ -756,7 +756,7 @@ pub fn try_send(&self, t: T) -> Result<(), TrySendError<T>> {
     }
 }
 
-#[unstable]
+#[stable]
 impl<T: Send> Clone for SyncSender<T> {
     fn clone(&self) -> SyncSender<T> {
         unsafe { (*self.inner.get()).clone_chan(); }
index e865bf42bd01d5239c6d912a05a6bba572d9526a..3a18b0dc1b525b495cb968a8b3dba01f2a13a7d4 100644 (file)
@@ -132,6 +132,7 @@ pub fn new(tx: Sender<Vec<u8>>) -> ChanWriter {
     }
 }
 
+#[stable]
 impl Clone for ChanWriter {
     fn clone(&self) -> ChanWriter {
         ChanWriter { tx: self.tx.clone() }