about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorEric Holk <eric.holk@gmail.com>2012-07-17 17:03:27 -0700
committerEric Holk <eric.holk@gmail.com>2012-07-17 17:46:31 -0700
commit7b8171ef2d03e4a2235b4bf0af255dab1b53bc25 (patch)
tree54194e622a33eacd1c3e04db66304a7c1e60fad0 /src/libstd
parentc858eb06546ce2be77fd284f707f76cb820c6211 (diff)
Added liveness analysis for protocols, and removed warnings about empty states.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/bitv.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs
index 74dadc556eb..1a3d5e08113 100644
--- a/src/libstd/bitv.rs
+++ b/src/libstd/bitv.rs
@@ -253,6 +253,14 @@ impl methods for bitv {
     fn each(f: fn(bool) -> bool) { each(self, f) }
     fn each_storage(f: fn(&uint) -> bool) { each_storage(self, f) }
     fn eq_vec(v: ~[uint]) -> bool { eq_vec(self, v) }
+
+    fn ones(f: fn(uint) -> bool) {
+        for uint::range(0, self.nbits) |i| {
+            if self.get(i) {
+                if !f(i) { break }
+            }
+        }
+    }
 }
 
 impl of to_str::to_str for bitv {