auto merge of #9115 : erickt/rust/master, r=erickt

This is a series of patches to modernize option and result. The highlights are:

* rename `.unwrap_or_default(value)` and etc to `.unwrap_or(value)`
* add `.unwrap_or_default()` that uses the `Default` trait
* add `Default` implementations for vecs, HashMap, Option
* add  `Option.and(T) -> Option<T>`, `Option.and_then(&fn() -> Option<T>) -> Option<T>`, `Option.or(T) -> Option<T>`, and `Option.or_else(&fn() -> Option<T>) -> Option<T>`
* add `option::ToOption`, `option::IntoOption`, `option::AsOption`, `result::ToResult`, `result::IntoResult`, `result::AsResult`, `either::ToEither`, and `either::IntoEither`, `either::AsEither`
* renamed `Option::chain*` and `Result::chain*` to `and_then` and `or_else` to avoid the eventual collision with `Iterator.chain`.
* Added a bunch of impls of `Default`
* Added a `#[deriving(Default)]` syntax extension
* Removed impls of `Zero` for `Option<T>` and vecs.
This commit is contained in:
bors 2013-09-14 00:01:04 -07:00
commit 2aa578efd9
55 changed files with 1102 additions and 230 deletions

View file

@ -24,15 +24,13 @@ struct E { a: int, b: int }
#[deriving(Zero)]
struct Lots {
c: Option<util::NonCopyable>,
d: u8,
e: char,
f: float,
g: (f32, char),
h: ~[util::NonCopyable],
i: @mut (int, int),
j: bool,
k: (),
h: @mut (int, int),
i: bool,
j: (),
}
fn main() {