1
Fork 0

Documentation of what does for each type

This commit is contained in:
athulappadan 2016-09-11 17:00:09 +05:30
parent 1fca1ab0e7
commit 49e77dbf25
32 changed files with 41 additions and 0 deletions

View file

@ -718,6 +718,7 @@ impl<T: ?Sized> Clone for Weak<T> {
#[stable(feature = "downgraded_weak", since = "1.10.0")]
impl<T> Default for Weak<T> {
/// Creates a new `Weak<T>`.
fn default() -> Weak<T> {
Weak::new()
}
@ -923,6 +924,7 @@ impl<T: ?Sized> fmt::Pointer for Arc<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Default> Default for Arc<T> {
/// Creates a new `Arc<T>`, with the `Default` value for T.
fn default() -> Arc<T> {
Arc::new(Default::default())
}

View file

@ -290,6 +290,7 @@ impl<T: ?Sized> Box<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Default> Default for Box<T> {
/// Creates a `Box<T>`, with the `Default` value for T.
fn default() -> Box<T> {
box Default::default()
}

View file

@ -870,6 +870,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
#[stable(feature = "downgraded_weak", since = "1.10.0")]
impl<T> Default for Weak<T> {
/// Creates a new `Weak<T>`.
fn default() -> Weak<T> {
Weak::new()
}

View file

@ -263,6 +263,7 @@ impl<T: Clone> Clone for BinaryHeap<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Default for BinaryHeap<T> {
/// Creates an empty `BinaryHeap<T>`.
#[inline]
fn default() -> BinaryHeap<T> {
BinaryHeap::new()

View file

@ -249,6 +249,7 @@ impl<'a, B: ?Sized> Default for Cow<'a, B>
where B: ToOwned,
<B as ToOwned>::Owned: Default
{
/// Creates a `Cow<'a, B>` pointer.
fn default() -> Cow<'a, B> {
Owned(<B as ToOwned>::Owned::default())
}

View file

@ -1667,6 +1667,7 @@ impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {
}
impl<K: Ord, V> Default for BTreeMap<K, V> {
/// Creates an empty `BTreeMap<K, V>`.
fn default() -> BTreeMap<K, V> {
BTreeMap::new()
}

View file

@ -674,6 +674,7 @@ impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BTreeSet<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Default for BTreeSet<T> {
/// Creates a new `BTreeSet<T>`.
fn default() -> BTreeSet<T> {
BTreeSet::new()
}

View file

@ -164,6 +164,7 @@ impl<T> LinkedList<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for LinkedList<T> {
/// Creates an empty `LinkedList<T>`.
#[inline]
fn default() -> Self {
Self::new()

View file

@ -1567,6 +1567,7 @@ impl_eq! { Cow<'a, str>, String }
#[stable(feature = "rust1", since = "1.0.0")]
impl Default for String {
/// Creates an empty `String`.
#[inline]
fn default() -> String {
String::new()

View file

@ -1610,6 +1610,7 @@ impl<T> Drop for Vec<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for Vec<T> {
/// Creates an empty `Vec<T>`.
fn default() -> Vec<T> {
Vec::new()
}

View file

@ -84,6 +84,7 @@ impl<T> Drop for VecDeque<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for VecDeque<T> {
/// Creates a `VecDeque<T>` with a constant initial capacity.
#[inline]
fn default() -> VecDeque<T> {
VecDeque::new()

View file

@ -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())
}

View file

@ -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)

View file

@ -698,6 +698,7 @@ fn expect_failed(msg: &str) -> ! {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for Option<T> {
/// Creates an instance of None.
#[inline]
fn default() -> Option<T> { None }
}

View file

@ -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 [] }
}

View file

@ -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 { "" }
}

View file

@ -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 an `AtomicPtr<T>` with an initial mutable null pointer.
fn default() -> AtomicPtr<T> {
AtomicPtr::new(::ptr::null_mut())
}

View file

@ -18,6 +18,7 @@ struct MyHasher {
}
impl Default for MyHasher {
/// Constructs a `MyHasher` with initial value zero.
fn default() -> MyHasher {
MyHasher { hash: 0 }
}
@ -90,6 +91,7 @@ impl Hasher for CustomHasher {
}
impl Default for CustomHasher {
/// Constructs a `CustomHasher` with initial value zero.
fn default() -> CustomHasher {
CustomHasher { output: 0 }
}

View file

@ -113,6 +113,7 @@ impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Default for ReseedWithDefault {
/// Creates an instance of `ReseedWithDefault`.
fn default() -> ReseedWithDefault {
ReseedWithDefault
}
@ -137,6 +138,7 @@ mod tests {
}
}
impl Default for Counter {
/// Constructs a `Counter` with initial value zero.
fn default() -> Counter {
Counter { i: 0 }
}

View file

@ -84,6 +84,7 @@ pub enum ErrorOutputType {
}
impl Default for ErrorOutputType {
/// Creates an `HumanReadble`, initialised with `ColorConfig` enum type `Auto`.
fn default() -> ErrorOutputType {
ErrorOutputType::HumanReadable(ColorConfig::Auto)
}

View file

@ -45,6 +45,7 @@ pub struct TargetDataLayout {
}
impl Default for TargetDataLayout {
/// Creates an instance of `TargetDataLayout`.
fn default() -> TargetDataLayout {
TargetDataLayout {
endian: Endian::Big,

View file

@ -35,6 +35,7 @@ pub fn FnvHashSet<V: Hash + Eq>() -> FnvHashSet<V> {
pub struct FnvHasher(u64);
impl Default for FnvHasher {
/// Creates a `FnvHasher`, with a 64-bit hex initial value.
#[inline]
fn default() -> FnvHasher {
FnvHasher(0xcbf29ce484222325)

View file

@ -109,6 +109,7 @@ enum SingleImports<'a> {
}
impl<'a> Default for SingleImports<'a> {
/// Creates a `SingleImports<'a>` of None type.
fn default() -> Self {
SingleImports::None
}

View file

@ -1218,6 +1218,7 @@ impl<K, V, S> Default for HashMap<K, V, S>
where K: Eq + Hash,
S: BuildHasher + Default,
{
/// Creates a `HashMap<K, V, S>`, with initial `Default` hasher.
fn default() -> HashMap<K, V, S> {
HashMap::with_hasher(Default::default())
}
@ -2026,6 +2027,7 @@ impl Hasher for DefaultHasher {
#[stable(feature = "rust1", since = "1.0.0")]
impl Default for RandomState {
/// Constructs a new `RandomState`.
#[inline]
fn default() -> RandomState {
RandomState::new()

View file

@ -665,6 +665,7 @@ impl<T, S> Default for HashSet<T, S>
where T: Eq + Hash,
S: BuildHasher + Default,
{
/// Creates a `HashSet<T, S>` with initial `Default` hasher.
fn default() -> HashSet<T, S> {
HashSet::with_hasher(Default::default())
}

View file

@ -339,6 +339,7 @@ impl<'a> Default for &'a CStr {
#[stable(feature = "cstr_default", since = "1.10.0")]
impl Default for CString {
/// Creates a new `CString`, by calling the `Default` of `CStr`, and then owns it.
fn default() -> CString {
let a: &CStr = Default::default();
a.to_owned()

View file

@ -170,6 +170,7 @@ impl ops::Deref for OsString {
#[stable(feature = "osstring_default", since = "1.9.0")]
impl Default for OsString {
/// Constructs an empty `OsString`.
#[inline]
fn default() -> OsString {
OsString::new()
@ -342,6 +343,7 @@ impl OsStr {
#[stable(feature = "osstring_default", since = "1.9.0")]
impl<'a> Default for &'a OsStr {
/// Creates an empty `OsStr`.
#[inline]
fn default() -> &'a OsStr {
OsStr::new("")

View file

@ -241,6 +241,7 @@ impl Condvar {
#[stable(feature = "condvar_default", since = "1.9.0")]
impl Default for Condvar {
/// Creates a `Condvar` which is ready to be waited on and notified.
fn default() -> Condvar {
Condvar::new()
}

View file

@ -287,6 +287,7 @@ impl<T: ?Sized> Drop for Mutex<T> {
#[stable(feature = "mutex_default", since = "1.9.0")]
impl<T: ?Sized + Default> Default for Mutex<T> {
/// Creates a `Mutex<T>`, with the `Default` value for T.
fn default() -> Mutex<T> {
Mutex::new(Default::default())
}

View file

@ -311,6 +311,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
#[stable(feature = "rw_lock_default", since = "1.9.0")]
impl<T: Default> Default for RwLock<T> {
/// Creates a new `RwLock<T>`, with the `Default` value for T.
fn default() -> RwLock<T> {
RwLock::new(Default::default())
}

View file

@ -362,6 +362,7 @@ impl Generics {
}
impl Default for Generics {
/// Creates an instance of `Generics`.
fn default() -> Generics {
Generics {
lifetimes: Vec::new(),

View file

@ -154,6 +154,7 @@ impl<T> P<[T]> {
}
impl<T> Default for P<[T]> {
/// Creates a new `P`, with the `Default` value for T.
fn default() -> P<[T]> {
P::new()
}