diff options
| author | Patrick Walton <[email protected]> | 2011-03-17 11:21:11 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-17 11:21:11 -0700 |
| commit | 84321d1f59232f547aefff16667b8a68f2c8bb57 (patch) | |
| tree | d64859bebfcbc00166ed4cc554300abb2e0712d5 /src/lib | |
| parent | rustc: Add str_from_cstr() and str_from_buf() functions to the standard libra... (diff) | |
| download | rust-84321d1f59232f547aefff16667b8a68f2c8bb57.tar.xz rust-84321d1f59232f547aefff16667b8a68f2c8bb57.zip | |
Add an option.is_none() method
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/option.rs | 7 |
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; |