Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
xmakro committed Jan 10, 2024
1 parent b00c785 commit 75c150f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rand_distr/src/weighted_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ impl<W: Weight> WeightedTreeIndex<W> {
///
/// This is the case if the total weight of the tree is greater than zero.
pub fn can_sample(&self) -> bool {
self.subtotals.first().is_some_and(|x| *x > W::zero())
if let Some(&w) = self.subtotals.first() {
w > W::zero()
} else {
false
}
}

/// Gets the weight at an index.
Expand Down

0 comments on commit 75c150f

Please sign in to comment.