Skip to content

Commit b10172f

Browse files
authored
Make fn WeightedTreeIndex::try_sample public
1 parent a2375dc commit b10172f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rand_distr/src/weighted_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl<W: Clone + PartialEq + PartialOrd + SampleUniform + SubAssign<W> + Weight>
247247
///
248248
/// Returns an error if there are no elements or all weights are zero. This
249249
/// is unlike [`Distribution::sample`], which panics in those cases.
250-
fn try_sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Result<usize, WeightError> {
250+
pub fn try_sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Result<usize, WeightError> {
251251
let total_weight = self.subtotals.first().cloned().unwrap_or(W::ZERO);
252252
if total_weight == W::ZERO {
253253
return Err(WeightError::InsufficientNonZero);

0 commit comments

Comments
 (0)