@@ -97,13 +97,6 @@ pub struct WeightedTreeIndex<
97
97
impl < W : Clone + PartialEq + PartialOrd + SampleUniform + SubAssign < W > + Weight >
98
98
WeightedTreeIndex < W >
99
99
{
100
- /// Creates a new [`WeightedTreeIndex`] without weights.
101
- pub fn new_empty ( ) -> Self {
102
- Self {
103
- subtotals : Vec :: new ( ) ,
104
- }
105
- }
106
-
107
100
/// Creates a new [`WeightedTreeIndex`] from a slice of weights.
108
101
///
109
102
/// Error cases:
@@ -310,7 +303,8 @@ mod test {
310
303
#[ test]
311
304
fn test_no_item_error ( ) {
312
305
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 ( ) ;
314
308
assert_eq ! (
315
309
tree. try_sample( & mut rng) . unwrap_err( ) ,
316
310
WeightError :: InsufficientNonZero
@@ -345,7 +339,8 @@ mod test {
345
339
WeightedTreeIndex :: <i32 >:: new( [ 1 , -1 ] ) . unwrap_err( ) ,
346
340
WeightError :: InvalidWeight
347
341
) ;
348
- let mut tree = WeightedTreeIndex :: < i32 > :: new_empty ( ) ;
342
+ #[ allow( clippy:: needless_borrows_for_generic_args) ]
343
+ let mut tree = WeightedTreeIndex :: < i32 > :: new ( & [ ] ) . unwrap ( ) ;
349
344
assert_eq ! ( tree. push( -1 ) . unwrap_err( ) , WeightError :: InvalidWeight ) ;
350
345
tree. push ( 1 ) . unwrap ( ) ;
351
346
assert_eq ! ( tree. update( 0 , -1 ) . unwrap_err( ) , WeightError :: InvalidWeight ) ;
0 commit comments