aboutsummaryrefslogtreecommitdiff
path: root/src/lib/option.rs
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-03-17 11:21:11 -0700
committerPatrick Walton <[email protected]>2011-03-17 11:21:11 -0700
commit84321d1f59232f547aefff16667b8a68f2c8bb57 (patch)
treed64859bebfcbc00166ed4cc554300abb2e0712d5 /src/lib/option.rs
parentrustc: Add str_from_cstr() and str_from_buf() functions to the standard libra... (diff)
downloadrust-84321d1f59232f547aefff16667b8a68f2c8bb57.tar.xz
rust-84321d1f59232f547aefff16667b8a68f2c8bb57.zip
Add an option.is_none() method
Diffstat (limited to 'src/lib/option.rs')
-rw-r--r--src/lib/option.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/option.rs b/src/lib/option.rs
index 25f82b52..29a6f6eb 100644
--- a/src/lib/option.rs
+++ b/src/lib/option.rs
@@ -31,6 +31,13 @@ fn map[T, U](&operator[T, U] f, &t[T] opt) -> t[U] {
fail; // FIXME: remove me when exhaustiveness checking works
}
+fn is_none[T](&t[T] opt) -> bool {
+ alt (opt) {
+ case (none[T]) { ret true; }
+ case (some[T](_)) { ret false; }
+ }
+}
+
// Local Variables:
// mode: rust;
// fill-column: 78;