Skip to content

Commit

Permalink
Remove WeightedTreeIndex::new_empty method
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed May 8, 2024
1 parent b26a5d5 commit cc7634d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions rand_distr/src/weighted_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ pub struct WeightedTreeIndex<
impl<W: Clone + PartialEq + PartialOrd + SampleUniform + SubAssign<W> + Weight>
WeightedTreeIndex<W>
{
/// Creates a new [`WeightedTreeIndex`] without weights.
pub fn new_empty() -> Self {
Self {
subtotals: Vec::new(),
}
}

/// Creates a new [`WeightedTreeIndex`] from a slice of weights.
///
/// Error cases:
Expand Down Expand Up @@ -310,7 +303,8 @@ mod test {
#[test]
fn test_no_item_error() {
let mut rng = crate::test::rng(0x9c9fa0b0580a7031);
let tree = WeightedTreeIndex::<f64>::new_empty();
#[allow(clippy::needless_borrows_for_generic_args)]
let tree = WeightedTreeIndex::<f64>::new(&[]).unwrap();
assert_eq!(
tree.try_sample(&mut rng).unwrap_err(),
WeightError::InsufficientNonZero
Expand Down Expand Up @@ -345,7 +339,8 @@ mod test {
WeightedTreeIndex::<i32>::new([1, -1]).unwrap_err(),
WeightError::InvalidWeight
);
let mut tree = WeightedTreeIndex::<i32>::new_empty();
#[allow(clippy::needless_borrows_for_generic_args)]
let mut tree = WeightedTreeIndex::<i32>::new(&[]).unwrap();
assert_eq!(tree.push(-1).unwrap_err(), WeightError::InvalidWeight);
tree.push(1).unwrap();
assert_eq!(tree.update(0, -1).unwrap_err(), WeightError::InvalidWeight);
Expand Down

0 comments on commit cc7634d

Please sign in to comment.