Skip to content

Provide documentation for Default impls #23271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ impl<T: fmt::Debug> fmt::Debug for Arc<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Default + Sync + Send> Default for Arc<T> {
/// Creates a new `Arc` using `Arc::new` with the `Default` value of `T`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Arc<T> { Arc::new(Default::default()) }
}
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ pub unsafe fn into_raw<T : ?Sized>(b: Box<T>) -> *mut T {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Default> Default for Box<T> {
/// Creates a new `Box<T>` by `box`ing the `Default` value of `T`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Box<T> { box Default::default() }
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for Box<[T]> {
/// Creates a new `Box<[T]>` by `box`ing an empty slice
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Box<[T]> { Box::<[T; 0]>::new([]) }
}
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ pub struct BinaryHeap<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Default for BinaryHeap<T> {
/// Creates a new `BinaryHeap` using `BinaryHeap::new`
#[inline]
fn default() -> BinaryHeap<T> { BinaryHeap::new() }
}
Expand Down
2 changes: 2 additions & 0 deletions src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ impl BitVec {

#[stable(feature = "rust1", since = "1.0.0")]
impl Default for BitVec {
/// Creates a new `BitVec` using `BitVec::new`
#[inline]
fn default() -> BitVec { BitVec::new() }
}
Expand Down Expand Up @@ -1128,6 +1129,7 @@ pub struct BitSet {

#[stable(feature = "rust1", since = "1.0.0")]
impl Default for BitSet {
/// Creates a new `BitSet` using `BitSet::new`
#[inline]
fn default() -> BitSet { BitSet::new() }
}
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<K: Ord, V> Default for BTreeMap<K, V> {
/// Creates a new `BTreeMap` using `BTreeMap::new`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> BTreeMap<K, V> {
BTreeMap::new()
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ impl<T: Ord> Extend<T> for BTreeSet<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Default for BTreeSet<T> {
/// Creates a new `BTreeSet` using `BTreeSet::new`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> BTreeSet<T> {
BTreeSet::new()
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ impl<T> LinkedList<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for LinkedList<T> {
/// Creates a new `LinkedList` using `LinkedList::new`
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> LinkedList<T> { LinkedList::new() }
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ impl Str for String {

#[stable(feature = "rust1", since = "1.0.0")]
impl Default for String {
/// Creates a new `String` using `String::new`
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> String {
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,7 @@ impl<T> Drop for Vec<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for Vec<T> {
/// Creates a new `Vec` using `Vec::new`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Vec<T> {
Vec::new()
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl<T> Drop for VecDeque<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for VecDeque<T> {
/// Creates a new `VecDeque` using `VecDeque::new`
#[inline]
fn default() -> VecDeque<T> { VecDeque::new() }
}
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/vec_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub struct OccupiedEntry<'a, V:'a> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<V> Default for VecMap<V> {
/// Creates a new `VecMap` using `VecMap::new`
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
fn default() -> VecMap<V> { VecMap::new() }
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,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 new `Cell` using `Cell::new` with the `Default` value of `T`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Cell<T> {
Cell::new(Default::default())
Expand Down Expand Up @@ -482,6 +483,7 @@ impl<T: Clone> Clone for RefCell<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T:Default> Default for RefCell<T> {
/// Creates a new `RefCell` using `RefCell::new` with the `Default` value of `T`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> RefCell<T> {
RefCell::new(Default::default())
Expand Down
1 change: 1 addition & 0 deletions src/libcore/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl Clone for SipHasher {

#[stable(feature = "rust1", since = "1.0.0")]
impl Default for SipHasher {
/// Creates a new `SipHasher` using `SipHasher::new`
fn default() -> SipHasher {
SipHasher::new()
}
Expand Down
1 change: 1 addition & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ impl<T> AsSlice<T> for Option<T> {

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for Option<T> {
/// Creates a new `Option` with value `None`
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> Option<T> { None }
Expand Down
1 change: 1 addition & 0 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a mut U {

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Default for &'a [T] {
/// Creates a new empty slice
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> &'a [T] { &[] }
}
Expand Down
1 change: 1 addition & 0 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,7 @@ pub fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) {

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Default for &'a str {
/// Creates a new empty string slice
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> &'a str { "" }
}
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ macro_rules! tuple_impls {

#[stable(feature = "rust1", since = "1.0.0")]
impl<$($T:Default),+> Default for ($($T,)+) {
/// Creates a new tuple containing the `Default` value for each of the type
/// parameters
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
fn default() -> ($($T,)+) {
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ impl<K, V, S> Default for HashMap<K, V, S>
where K: Eq + Hash,
S: HashState + Default,
{
/// Creates a new `HashMap` using `HashMap::with_hash_state` with the `Default` value for `S`
fn default() -> HashMap<K, V, S> {
HashMap::with_hash_state(Default::default())
}
Expand Down Expand Up @@ -1600,6 +1601,7 @@ impl HashState for RandomState {
reason = "hashing an hash maps may be altered")]
impl Default for RandomState {
#[inline]
/// Creates a new `RandomState` using `RandomState::new`
fn default() -> RandomState {
RandomState::new()
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ impl<T, S> Default for HashSet<T, S>
where T: Eq + Hash,
S: HashState + Default,
{
/// Creates a new `HashSet` using `HashSet::with_hash_state` with the `Default` value for `S`
#[stable(feature = "rust1", since = "1.0.0")]
fn default() -> HashSet<T, S> {
HashSet::with_hash_state(Default::default())
Expand Down
1 change: 1 addition & 0 deletions src/libstd/collections/hash/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ impl<H> Clone for DefaultState<H> {
}

impl<H> Default for DefaultState<H> {
/// Creates a new `DefaultState`
fn default() -> DefaultState<H> { DefaultState(marker::PhantomData) }
}
1 change: 1 addition & 0 deletions src/libsyntax/owned_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl<T> Deref for OwnedSlice<T> {
}

impl<T> Default for OwnedSlice<T> {
/// Creates a new `OwnedSlice` using `OwnedSlice::empty`
fn default() -> OwnedSlice<T> {
OwnedSlice::empty()
}
Expand Down