Skip to content

Commit c221113

Browse files
authored
Add an auto_resize accessor to Histogram (#106)
1 parent f3d134f commit c221113

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ impl<T: Counter> Histogram<T> {
344344
self.bucket_count
345345
}
346346

347+
/// Returns true if this histogram is currently able to auto-resize as new samples are recorded.
348+
pub fn is_auto_resize(&self) -> bool {
349+
self.auto_resize
350+
}
351+
347352
// ********************************************************************************************
348353
// Methods for looking up the count for a given value/index
349354
// ********************************************************************************************

tests/auto_resize.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,12 @@ fn autosizing_across_continuous_range() {
4848
histogram += i;
4949
}
5050
}
51+
52+
#[test]
53+
fn can_acess_autoresize_setting() {
54+
let mut histogram = Histogram::<u64>::new(2).unwrap();
55+
assert!(histogram.is_auto_resize());
56+
57+
histogram.auto(false);
58+
assert!(!histogram.is_auto_resize());
59+
}

0 commit comments

Comments
 (0)