diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-09-14 17:15:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-14 17:15:37 +0200 |
| commit | a89690ec00ca98397183c3ef011f944448098f8b (patch) | |
| tree | 223b94f42aed89fbfb7fd84a474cf2bb64b45694 /src/libcore | |
| parent | 4476b7b43b2826b6f0e71f4638159f8718c0a440 (diff) | |
| parent | 5798003438469313c0616270b8b285d9afbb4730 (diff) | |
| download | rust-a89690ec00ca98397183c3ef011f944448098f8b.tar.gz rust-a89690ec00ca98397183c3ef011f944448098f8b.zip | |
Rollup merge of #36396 - athulappadan:Default-docs, r=bluss
Documentation of what Default does for each type Addresses #36265 I haven't changed the following types due to doubts: 1)src/libstd/ffi/c_str.rs 2)src/libcore/iter/sources.rs 3)src/libcore/hash/mod.rs 4)src/libcore/hash/mod.rs 5)src/librustc/middle/privacy.rs r? @steveklabnik
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 3 | ||||
| -rw-r--r-- | src/libcore/hash/sip.rs | 1 | ||||
| -rw-r--r-- | src/libcore/option.rs | 1 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 2 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 1 | ||||
| -rw-r--r-- | src/libcore/sync/atomic.rs | 2 |
6 files changed, 10 insertions, 0 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index f0710a1d935..51221f1b9b9 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -317,6 +317,7 @@ impl<T:Copy> Clone for Cell<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T:Default + Copy> Default for Cell<T> { + /// Creates a `Cell<T>`, with the `Default` value for T. #[inline] fn default() -> Cell<T> { Cell::new(Default::default()) @@ -758,6 +759,7 @@ impl<T: Clone> Clone for RefCell<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T:Default> Default for RefCell<T> { + /// Creates a `RefCell<T>`, with the `Default` value for T. #[inline] fn default() -> RefCell<T> { RefCell::new(Default::default()) @@ -1139,6 +1141,7 @@ impl<T: ?Sized> UnsafeCell<T> { #[stable(feature = "unsafe_cell_default", since = "1.9.0")] impl<T: Default> Default for UnsafeCell<T> { + /// Creates an `UnsafeCell`, with the `Default` value for T. fn default() -> UnsafeCell<T> { UnsafeCell::new(Default::default()) } diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index bd6cae92b05..dc53683d633 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -333,6 +333,7 @@ impl<S: Sip> Clone for Hasher<S> { } impl<S: Sip> Default for Hasher<S> { + /// Creates a `Hasher<S>` with the two initial keys set to 0. #[inline] fn default() -> Hasher<S> { Hasher::new_with_keys(0, 0) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index dacb396ee40..b9fb2dc90c7 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -714,6 +714,7 @@ fn expect_failed(msg: &str) -> ! { #[stable(feature = "rust1", since = "1.0.0")] impl<T> Default for Option<T> { + /// Returns None. #[inline] fn default() -> Option<T> { None } } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index b22bdb43414..7b147faccd2 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -755,11 +755,13 @@ impl<T> ops::IndexMut<ops::RangeToInclusive<usize>> for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Default for &'a [T] { + /// Creates an empty slice. fn default() -> &'a [T] { &[] } } #[stable(feature = "mut_slice_default", since = "1.5.0")] impl<'a, T> Default for &'a mut [T] { + /// Creates a mutable empty slice. fn default() -> &'a mut [T] { &mut [] } } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 18e43c02c64..1f1ae6f12ab 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1987,5 +1987,6 @@ impl AsRef<[u8]> for str { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Default for &'a str { + /// Creates an empty str fn default() -> &'a str { "" } } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 75ddd2021a8..f5f37be52de 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -95,6 +95,7 @@ pub struct AtomicBool { #[cfg(target_has_atomic = "8")] #[stable(feature = "rust1", since = "1.0.0")] impl Default for AtomicBool { + /// Creates an `AtomicBool` initialised as false. fn default() -> Self { Self::new(false) } @@ -117,6 +118,7 @@ pub struct AtomicPtr<T> { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "rust1", since = "1.0.0")] impl<T> Default for AtomicPtr<T> { + /// Creates a null `AtomicPtr<T>`. fn default() -> AtomicPtr<T> { AtomicPtr::new(::ptr::null_mut()) } |
