(index<- ) ./libcore/default.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Fri May 9 13:02:28 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 use owned::Box;
14
15 /// A trait that types which have a useful default value should implement.
16 pub trait Default {
17 /// Return the "default value" for a type.
18 fn default() -> Self;
19 }
20
21 impl<T: Default + 'static> Default for @T {
22 fn default() -> @T { @Default::default() }
23 }
24
25 impl<T: Default> Default for Box<T> {
26 fn default() -> Box<T> { box Default::default() }
27 }