From 7b8171ef2d03e4a2235b4bf0af255dab1b53bc25 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 17 Jul 2012 17:03:27 -0700 Subject: Added liveness analysis for protocols, and removed warnings about empty states. --- src/libstd/bitv.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libstd') 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 { -- cgit 1.4.1-3-g733a5