diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/bitv.rs | 8 |
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 { |
