(index<- ) ./libstd/default.rs
git branch: * master c7553ea auto merge of #13609 : richo/rust/str-type-vim, r=alexcrichton
modified: Sat Feb 15 17:22:38 2014
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 }