From 7a41672c6e3a8ad5d45c8562f7a7e962db29edb2 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Thu, 10 Mar 2016 19:01:15 -0500 Subject: [PATCH] Tidy formatting --- src/lib.rs | 49 ++++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cee18db..a034461 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,8 +57,7 @@ use std::cmp::Ordering; use std::cmp; use std::fmt; use std::hash; -use std::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat}; -use std::iter::{self, FromIterator}; +use std::iter::{self, Chain, Enumerate, FromIterator, Repeat, Skip, Take}; type MatchWords<'a, B> = Chain>, Skip>>>>; @@ -81,8 +80,9 @@ fn blocks_for_bits(bits: usize) -> usize { // Take two BitVec's, and return iterators of their words, where the shorter one // has been padded with 0's -fn match_words<'a,'b, B: BitBlock>(a: &'a BitVec, b: &'b BitVec) - -> (MatchWords<'a, B>, MatchWords<'b, B>) { +fn match_words<'a, 'b, B: BitBlock>(a: &'a BitVec, b: &'b BitVec) + -> (MatchWords<'a, B>, MatchWords<'b, B>) +{ let a_len = a.storage().len(); let b_len = b.storage().len(); @@ -96,16 +96,16 @@ fn match_words<'a,'b, B: BitBlock>(a: &'a BitVec, b: &'b BitVec) } } -pub struct BitSet { +pub struct BitSet { bit_vec: BitVec, } impl Clone for BitSet { - fn clone(&self) -> Self { - BitSet { - bit_vec: self.bit_vec.clone(), - } - } + fn clone(&self) -> Self { + BitSet { + bit_vec: self.bit_vec.clone(), + } + } } impl Default for BitSet { @@ -114,8 +114,8 @@ impl Default for BitSet { } impl FromIterator for BitSet { - fn from_iter>(iter: I) -> Self { - let mut ret: Self = Default::default(); + fn from_iter>(iter: I) -> Self { + let mut ret = Self::default(); ret.extend(iter); ret } @@ -123,7 +123,7 @@ impl FromIterator for BitSet { impl Extend for BitSet { #[inline] - fn extend>(&mut self, iter: I) { + fn extend>(&mut self, iter: I) { for i in iter { self.insert(i); } @@ -156,14 +156,14 @@ impl Ord for BitSet { } } -impl cmp::PartialEq for BitSet { +impl PartialEq for BitSet { #[inline] fn eq(&self, other: &Self) -> bool { self.cmp(other) == Ordering::Equal } } -impl cmp::Eq for BitSet {} +impl Eq for BitSet {} impl BitSet { /// Creates a new empty `BitSet`. @@ -177,7 +177,7 @@ impl BitSet { /// ``` #[inline] pub fn new() -> Self { - Default::default() + Self::default() } /// Creates a new `BitSet` with initially no contents, able to @@ -194,7 +194,7 @@ impl BitSet { #[inline] pub fn with_capacity(nbits: usize) -> Self { let bit_vec = BitVec::from_elem(nbits, false); - BitSet::from_bit_vec(bit_vec) + Self::from_bit_vec(bit_vec) } /// Creates a new `BitSet` from the given bit vector. @@ -294,7 +294,6 @@ impl BitSet { } } - /// Consumes this set to return the underlying bit vector. /// /// # Examples @@ -358,7 +357,7 @@ impl BitSet { let old = self_bit_vec.storage()[i]; let new = f(old, w); unsafe { - self_bit_vec.storage_mut()[i] = new; + self_bit_vec.storage_mut()[i] = new; } } } @@ -391,8 +390,8 @@ impl BitSet { // Truncate let trunc_len = cmp::max(old_len - n, 1); unsafe { - bit_vec.storage_mut().truncate(trunc_len); - bit_vec.set_len(trunc_len * B::bits()); + bit_vec.storage_mut().truncate(trunc_len); + bit_vec.set_len(trunc_len * B::bits()); } } @@ -954,14 +953,6 @@ impl<'a, B: BitBlock> IntoIterator for &'a BitSet { } } - - - - - - - - #[cfg(test)] mod tests { use std::cmp::Ordering::{Equal, Greater, Less}; -- 2.44.0