Skip to content

Commit cc7634d

Browse files
committed
Remove WeightedTreeIndex::new_empty method
1 parent b26a5d5 commit cc7634d

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

rand_distr/src/weighted_tree.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ pub struct WeightedTreeIndex<
9797
impl<W: Clone + PartialEq + PartialOrd + SampleUniform + SubAssign<W> + Weight>
9898
WeightedTreeIndex<W>
9999
{
100-
/// Creates a new [`WeightedTreeIndex`] without weights.
101-
pub fn new_empty() -> Self {
102-
Self {
103-
subtotals: Vec::new(),
104-
}
105-
}
106-
107100
/// Creates a new [`WeightedTreeIndex`] from a slice of weights.
108101
///
109102
/// Error cases:
@@ -310,7 +303,8 @@ mod test {
310303
#[test]
311304
fn test_no_item_error() {
312305
let mut rng = crate::test::rng(0x9c9fa0b0580a7031);
313-
let tree = WeightedTreeIndex::<f64>::new_empty();
306+
#[allow(clippy::needless_borrows_for_generic_args)]
307+
let tree = WeightedTreeIndex::<f64>::new(&[]).unwrap();
314308
assert_eq!(
315309
tree.try_sample(&mut rng).unwrap_err(),
316310
WeightError::InsufficientNonZero
@@ -345,7 +339,8 @@ mod test {
345339
WeightedTreeIndex::<i32>::new([1, -1]).unwrap_err(),
346340
WeightError::InvalidWeight
347341
);
348-
let mut tree = WeightedTreeIndex::<i32>::new_empty();
342+
#[allow(clippy::needless_borrows_for_generic_args)]
343+
let mut tree = WeightedTreeIndex::<i32>::new(&[]).unwrap();
349344
assert_eq!(tree.push(-1).unwrap_err(), WeightError::InvalidWeight);
350345
tree.push(1).unwrap();
351346
assert_eq!(tree.update(0, -1).unwrap_err(), WeightError::InvalidWeight);

0 commit comments

Comments
 (0)