Skip to content

Commit 49e77db

Browse files
committed
Documentation of what does for each type
1 parent 1fca1ab commit 49e77db

File tree

32 files changed

+41
-0
lines changed

32 files changed

+41
-0
lines changed

src/liballoc/arc.rs

+2
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+
/// Creates a new `Weak<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

+1
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

+1
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

+1
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

+1
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 a `Cow<'a, B>` pointer.
252253
fn default() -> Cow<'a, B> {
253254
Owned(<B as ToOwned>::Owned::default())
254255
}

src/libcollections/btree/map.rs

+1
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

+1
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+
/// Creates a new `BTreeSet<T>`.
677678
fn default() -> BTreeSet<T> {
678679
BTreeSet::new()
679680
}

src/libcollections/linked_list.rs

+1
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

+1
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

+1
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,7 @@ impl<T> Drop for Vec<T> {
16101610

16111611
#[stable(feature = "rust1", since = "1.0.0")]
16121612
impl<T> Default for Vec<T> {
1613+
/// Creates an empty `Vec<T>`.
16131614
fn default() -> Vec<T> {
16141615
Vec::new()
16151616
}

src/libcollections/vec_deque.rs

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ impl<T> Drop for VecDeque<T> {
8484

8585
#[stable(feature = "rust1", since = "1.0.0")]
8686
impl<T> Default for VecDeque<T> {
87+
/// Creates a `VecDeque<T>` with a constant initial capacity.
8788
#[inline]
8889
fn default() -> VecDeque<T> {
8990
VecDeque::new()

src/libcore/cell.rs

+3
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ impl<T:Copy> Clone for Cell<T> {
317317

318318
#[stable(feature = "rust1", since = "1.0.0")]
319319
impl<T:Default + Copy> Default for Cell<T> {
320+
/// Creates a `Cell<T>`, with the `Default` value for T.
320321
#[inline]
321322
fn default() -> Cell<T> {
322323
Cell::new(Default::default())
@@ -758,6 +759,7 @@ impl<T: Clone> Clone for RefCell<T> {
758759

759760
#[stable(feature = "rust1", since = "1.0.0")]
760761
impl<T:Default> Default for RefCell<T> {
762+
/// Creates a `RefCell<T>`, with the `Default` value for T.
761763
#[inline]
762764
fn default() -> RefCell<T> {
763765
RefCell::new(Default::default())
@@ -1139,6 +1141,7 @@ impl<T: ?Sized> UnsafeCell<T> {
11391141

11401142
#[stable(feature = "unsafe_cell_default", since = "1.9.0")]
11411143
impl<T: Default> Default for UnsafeCell<T> {
1144+
/// Creates an `UnsafeCell`, with the `Default` value for T.
11421145
fn default() -> UnsafeCell<T> {
11431146
UnsafeCell::new(Default::default())
11441147
}

src/libcore/hash/sip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ impl<S: Sip> Clone for Hasher<S> {
333333
}
334334

335335
impl<S: Sip> Default for Hasher<S> {
336+
/// Creates a `Hasher<S>` with the two initial keys set to 0.
336337
#[inline]
337338
fn default() -> Hasher<S> {
338339
Hasher::new_with_keys(0, 0)

src/libcore/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ fn expect_failed(msg: &str) -> ! {
698698

699699
#[stable(feature = "rust1", since = "1.0.0")]
700700
impl<T> Default for Option<T> {
701+
/// Creates an instance of None.
701702
#[inline]
702703
fn default() -> Option<T> { None }
703704
}

src/libcore/slice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,13 @@ impl<T> ops::IndexMut<ops::RangeToInclusive<usize>> for [T] {
755755

756756
#[stable(feature = "rust1", since = "1.0.0")]
757757
impl<'a, T> Default for &'a [T] {
758+
/// Creates an empty Slice.
758759
fn default() -> &'a [T] { &[] }
759760
}
760761

761762
#[stable(feature = "mut_slice_default", since = "1.5.0")]
762763
impl<'a, T> Default for &'a mut [T] {
764+
/// Creates a mutable empty Slice.
763765
fn default() -> &'a mut [T] { &mut [] }
764766
}
765767

src/libcore/str/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1987,5 +1987,6 @@ impl AsRef<[u8]> for str {
19871987

19881988
#[stable(feature = "rust1", since = "1.0.0")]
19891989
impl<'a> Default for &'a str {
1990+
/// Creates an empty str
19901991
fn default() -> &'a str { "" }
19911992
}

src/libcore/sync/atomic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub struct AtomicBool {
9595
#[cfg(target_has_atomic = "8")]
9696
#[stable(feature = "rust1", since = "1.0.0")]
9797
impl Default for AtomicBool {
98+
/// Creates an `AtomicBool` initialised as false.
9899
fn default() -> Self {
99100
Self::new(false)
100101
}
@@ -117,6 +118,7 @@ pub struct AtomicPtr<T> {
117118
#[cfg(target_has_atomic = "ptr")]
118119
#[stable(feature = "rust1", since = "1.0.0")]
119120
impl<T> Default for AtomicPtr<T> {
121+
/// Creates an `AtomicPtr<T>` with an initial mutable null pointer.
120122
fn default() -> AtomicPtr<T> {
121123
AtomicPtr::new(::ptr::null_mut())
122124
}

src/libcoretest/hash/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct MyHasher {
1818
}
1919

2020
impl Default for MyHasher {
21+
/// Constructs a `MyHasher` with initial value zero.
2122
fn default() -> MyHasher {
2223
MyHasher { hash: 0 }
2324
}
@@ -90,6 +91,7 @@ impl Hasher for CustomHasher {
9091
}
9192

9293
impl Default for CustomHasher {
94+
/// Constructs a `CustomHasher` with initial value zero.
9395
fn default() -> CustomHasher {
9496
CustomHasher { output: 0 }
9597
}

src/librand/reseeding.rs

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {
113113
}
114114
#[stable(feature = "rust1", since = "1.0.0")]
115115
impl Default for ReseedWithDefault {
116+
/// Creates an instance of `ReseedWithDefault`.
116117
fn default() -> ReseedWithDefault {
117118
ReseedWithDefault
118119
}
@@ -137,6 +138,7 @@ mod tests {
137138
}
138139
}
139140
impl Default for Counter {
141+
/// Constructs a `Counter` with initial value zero.
140142
fn default() -> Counter {
141143
Counter { i: 0 }
142144
}

src/librustc/session/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub enum ErrorOutputType {
8484
}
8585

8686
impl Default for ErrorOutputType {
87+
/// Creates an `HumanReadble`, initialised with `ColorConfig` enum type `Auto`.
8788
fn default() -> ErrorOutputType {
8889
ErrorOutputType::HumanReadable(ColorConfig::Auto)
8990
}

src/librustc/ty/layout.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub struct TargetDataLayout {
4545
}
4646

4747
impl Default for TargetDataLayout {
48+
/// Creates an instance of `TargetDataLayout`.
4849
fn default() -> TargetDataLayout {
4950
TargetDataLayout {
5051
endian: Endian::Big,

src/librustc_data_structures/fnv.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub fn FnvHashSet<V: Hash + Eq>() -> FnvHashSet<V> {
3535
pub struct FnvHasher(u64);
3636

3737
impl Default for FnvHasher {
38+
/// Creates a `FnvHasher`, with a 64-bit hex initial value.
3839
#[inline]
3940
fn default() -> FnvHasher {
4041
FnvHasher(0xcbf29ce484222325)

src/librustc_resolve/resolve_imports.rs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ enum SingleImports<'a> {
109109
}
110110

111111
impl<'a> Default for SingleImports<'a> {
112+
/// Creates a `SingleImports<'a>` of None type.
112113
fn default() -> Self {
113114
SingleImports::None
114115
}

src/libstd/collections/hash/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,7 @@ impl<K, V, S> Default for HashMap<K, V, S>
12181218
where K: Eq + Hash,
12191219
S: BuildHasher + Default,
12201220
{
1221+
/// Creates a `HashMap<K, V, S>`, with initial `Default` hasher.
12211222
fn default() -> HashMap<K, V, S> {
12221223
HashMap::with_hasher(Default::default())
12231224
}
@@ -2026,6 +2027,7 @@ impl Hasher for DefaultHasher {
20262027

20272028
#[stable(feature = "rust1", since = "1.0.0")]
20282029
impl Default for RandomState {
2030+
/// Constructs a new `RandomState`.
20292031
#[inline]
20302032
fn default() -> RandomState {
20312033
RandomState::new()

src/libstd/collections/hash/set.rs

+1
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ impl<T, S> Default for HashSet<T, S>
665665
where T: Eq + Hash,
666666
S: BuildHasher + Default,
667667
{
668+
/// Creates a `HashSet<T, S>` with initial `Default` hasher.
668669
fn default() -> HashSet<T, S> {
669670
HashSet::with_hasher(Default::default())
670671
}

src/libstd/ffi/c_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ impl<'a> Default for &'a CStr {
339339

340340
#[stable(feature = "cstr_default", since = "1.10.0")]
341341
impl Default for CString {
342+
/// Creates a new `CString`, by calling the `Default` of `CStr`, and then owns it.
342343
fn default() -> CString {
343344
let a: &CStr = Default::default();
344345
a.to_owned()

src/libstd/ffi/os_str.rs

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ impl ops::Deref for OsString {
170170

171171
#[stable(feature = "osstring_default", since = "1.9.0")]
172172
impl Default for OsString {
173+
/// Constructs an empty `OsString`.
173174
#[inline]
174175
fn default() -> OsString {
175176
OsString::new()
@@ -342,6 +343,7 @@ impl OsStr {
342343

343344
#[stable(feature = "osstring_default", since = "1.9.0")]
344345
impl<'a> Default for &'a OsStr {
346+
/// Creates an empty `OsStr`.
345347
#[inline]
346348
fn default() -> &'a OsStr {
347349
OsStr::new("")

src/libstd/sync/condvar.rs

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ impl Condvar {
241241

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

src/libstd/sync/mutex.rs

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ impl<T: ?Sized> Drop for Mutex<T> {
287287

288288
#[stable(feature = "mutex_default", since = "1.9.0")]
289289
impl<T: ?Sized + Default> Default for Mutex<T> {
290+
/// Creates a `Mutex<T>`, with the `Default` value for T.
290291
fn default() -> Mutex<T> {
291292
Mutex::new(Default::default())
292293
}

src/libstd/sync/rwlock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLock<T> {
311311

312312
#[stable(feature = "rw_lock_default", since = "1.9.0")]
313313
impl<T: Default> Default for RwLock<T> {
314+
/// Creates a new `RwLock<T>`, with the `Default` value for T.
314315
fn default() -> RwLock<T> {
315316
RwLock::new(Default::default())
316317
}

src/libsyntax/ast.rs

+1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ impl Generics {
362362
}
363363

364364
impl Default for Generics {
365+
/// Creates an instance of `Generics`.
365366
fn default() -> Generics {
366367
Generics {
367368
lifetimes: Vec::new(),

src/libsyntax/ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ impl<T> P<[T]> {
154154
}
155155

156156
impl<T> Default for P<[T]> {
157+
/// Creates a new `P`, with the `Default` value for T.
157158
fn default() -> P<[T]> {
158159
P::new()
159160
}

0 commit comments

Comments
 (0)