Skip to content

Commit

Permalink
Make fn WeightedTreeIndex::try_sample public
Browse files Browse the repository at this point in the history
  • Loading branch information
xmakro committed May 7, 2024
1 parent a2375dc commit b10172f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rand_distr/src/weighted_tree.rs
Expand Up @@ -247,7 +247,7 @@ impl<W: Clone + PartialEq + PartialOrd + SampleUniform + SubAssign<W> + Weight>
///
/// Returns an error if there are no elements or all weights are zero. This
/// is unlike [`Distribution::sample`], which panics in those cases.
fn try_sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Result<usize, WeightError> {
pub fn try_sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Result<usize, WeightError> {
let total_weight = self.subtotals.first().cloned().unwrap_or(W::ZERO);
if total_weight == W::ZERO {
return Err(WeightError::InsufficientNonZero);
Expand Down

0 comments on commit b10172f

Please sign in to comment.