]> git.lizzy.rs Git - rust.git/blob - src/libstd/default.rs
auto merge of #11304 : alexcrichton/rust/eintr, r=brson
[rust.git] / src / libstd / default.rs
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! The `Default` trait for types which may have meaningful default values
12
13 /// A trait that types which have a useful default value should implement.
14 pub trait Default {
15     /// Return the "default value" for a type.
16     fn default() -> Self;
17 }
18
19 impl<T: Default + 'static> Default for @T {
20     fn default() -> @T { @Default::default() }
21 }
22
23 impl<T: Default> Default for ~T {
24     fn default() -> ~T { ~Default::default() }
25 }