Skip to content

Commit bd878c1

Browse files
authored
Merge pull request #21 from marshallpierce/tidy-use-declarations
Three std::cmp's is probably enough. Other cleanup.
2 parents ae305fc + 382a55b commit bd878c1

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/lib.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,9 @@
150150

151151
extern crate num;
152152

153-
use std::ops::Index;
154-
use std::ops::IndexMut;
155-
use std::ops::AddAssign;
156-
use std::ops::SubAssign;
157153
use std::borrow::Borrow;
154+
use std::cmp;
155+
use std::ops::{Index, IndexMut, AddAssign, SubAssign};
158156

159157
use iterators::HistogramIterator;
160158

@@ -696,8 +694,7 @@ impl<T: Counter> Histogram<T> {
696694

697695
/// Allocate a counts array of the given size.
698696
fn alloc(&mut self, len: usize) {
699-
use std::iter;
700-
self.counts = iter::repeat(T::zero()).take(len).collect();
697+
self.counts = std::iter::repeat(T::zero()).take(len).collect();
701698
}
702699

703700
// ********************************************************************************************
@@ -1078,8 +1075,6 @@ impl<T: Counter> Histogram<T> {
10781075
///
10791076
/// Two values are considered "equivalent" if `self.equivalent` would return true.
10801077
pub fn percentile_below(&self, value: u64) -> f64 {
1081-
use std::cmp;
1082-
10831078
if self.total_count == 0 {
10841079
return 100.0;
10851080
}
@@ -1101,7 +1096,6 @@ impl<T: Counter> Histogram<T> {
11011096
///
11021097
/// May fail if the given values are out of bounds.
11031098
pub fn count_between(&self, low: u64, high: u64) -> Result<T, ()> {
1104-
use std::cmp;
11051099
let low_index = self.index_for(low);
11061100
let high_index = cmp::min(self.index_for(high), self.last());
11071101
Ok((low_index..(high_index + 1)).map(|i| self[i]).fold(T::zero(), |t, v| t + v))
@@ -1115,7 +1109,6 @@ impl<T: Counter> Histogram<T> {
11151109
///
11161110
/// May fail if the given value is out of bounds.
11171111
pub fn count_at(&self, value: u64) -> Result<T, ()> {
1118-
use std::cmp;
11191112
Ok(self[cmp::min(self.index_for(value), self.last())])
11201113
}
11211114

0 commit comments

Comments
 (0)