stdlib: Add option::is_some

This commit is contained in:
Brian Anderson 2011-06-16 10:52:43 -07:00
parent 49a4867da6
commit 0efd7fac8a

View File

@ -21,6 +21,10 @@ fn is_none[T](&t[T] opt) -> bool {
ret alt (opt) { case (none) { true } case (some(_)) { false } };
}
fn is_some[T](&t[T] opt) -> bool {
ret !is_none(opt);
}
fn from_maybe[T](&T def, &t[T] opt) -> T {
auto f = bind util::id[T](_);
ret maybe[T, T](def, f, opt);