Skip to content

Commit a89690e

Browse files
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
2 parents 4476b7b + 5798003 commit a89690e

File tree

30 files changed

+38
-0
lines changed

30 files changed

+38
-0
lines changed

src/liballoc/arc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ impl<T: ?Sized> Clone for Weak<T> {
718718

719719
#[stable(feature = "downgraded_weak", since = "1.10.0")]
720720
impl<T> Default for Weak<T> {
721+
/// Constructs a new `Weak<T>` without an accompanying instance of T.
721722
fn default() -> Weak<T> {
722723
Weak::new()
723724
}
@@ -923,6 +924,7 @@ impl<T: ?Sized> fmt::Pointer for Arc<T> {
923924

924925
#[stable(feature = "rust1", since = "1.0.0")]
925926
impl<T: Default> Default for Arc<T> {
927+
/// Creates a new `Arc<T>`, with the `Default` value for T.
926928
fn default() -> Arc<T> {
927929
Arc::new(Default::default())
928930
}

src/liballoc/boxed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ impl<T: ?Sized> Box<T> {
290290

291291
#[stable(feature = "rust1", since = "1.0.0")]
292292
impl<T: Default> Default for Box<T> {
293+
/// Creates a `Box<T>`, with the `Default` value for T.
293294
fn default() -> Box<T> {
294295
box Default::default()
295296
}

src/liballoc/rc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
870870

871871
#[stable(feature = "downgraded_weak", since = "1.10.0")]
872872
impl<T> Default for Weak<T> {
873+
/// Creates a new `Weak<T>`.
873874
fn default() -> Weak<T> {
874875
Weak::new()
875876
}

src/libcollections/binary_heap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ impl<T: Clone> Clone for BinaryHeap<T> {
263263

264264
#[stable(feature = "rust1", since = "1.0.0")]
265265
impl<T: Ord> Default for BinaryHeap<T> {
266+
/// Creates an empty `BinaryHeap<T>`.
266267
#[inline]
267268
fn default() -> BinaryHeap<T> {
268269
BinaryHeap::new()

src/libcollections/borrow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ impl<'a, B: ?Sized> Default for Cow<'a, B>
249249
where B: ToOwned,
250250
<B as ToOwned>::Owned: Default
251251
{
252+
/// Creates an owned Cow<'a, B> with the default value for the contained owned value.
252253
fn default() -> Cow<'a, B> {
253254
Owned(<B as ToOwned>::Owned::default())
254255
}

src/libcollections/btree/map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,7 @@ impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {
16671667
}
16681668

16691669
impl<K: Ord, V> Default for BTreeMap<K, V> {
1670+
/// Creates an empty `BTreeMap<K, V>`.
16701671
fn default() -> BTreeMap<K, V> {
16711672
BTreeMap::new()
16721673
}

src/libcollections/btree/set.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BTreeSet<T> {
674674

675675
#[stable(feature = "rust1", since = "1.0.0")]
676676
impl<T: Ord> Default for BTreeSet<T> {
677+
/// Makes an empty `BTreeSet<T>` with a reasonable choice of B.
677678
fn default() -> BTreeSet<T> {
678679
BTreeSet::new()
679680
}

src/libcollections/linked_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ impl<T> LinkedList<T> {
164164

165165
#[stable(feature = "rust1", since = "1.0.0")]
166166
impl<T> Default for LinkedList<T> {
167+
/// Creates an empty `LinkedList<T>`.
167168
#[inline]
168169
fn default() -> Self {
169170
Self::new()

src/libcollections/string.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@ impl_eq! { Cow<'a, str>, String }
15671567

15681568
#[stable(feature = "rust1", since = "1.0.0")]
15691569
impl Default for String {
1570+
/// Creates an empty `String`.
15701571
#[inline]
15711572
fn default() -> String {
15721573
String::new()

src/libcollections/vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@ impl<T> Drop for Vec<T> {
16521652

16531653
#[stable(feature = "rust1", since = "1.0.0")]
16541654
impl<T> Default for Vec<T> {
1655+
/// Creates an empty `Vec<T>`.
16551656
fn default() -> Vec<T> {
16561657
Vec::new()
16571658
}

0 commit comments

Comments
 (0)