Skip to content

Commit 8f6a8c5

Browse files
committed
Add deprecated fn wrappers
1 parent dad5f7c commit 8f6a8c5

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/seq/iterator.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,25 @@ pub trait IteratorRandom: Iterator + Sized {
262262
}
263263
reservoir
264264
}
265+
266+
/// Deprecated: use [`Self::sample_fill`] instead
267+
#[deprecated(since = "0.9.2", note = "Renamed to `sample_fill`")]
268+
fn choose_multiple_fill<R>(self, rng: &mut R, buf: &mut [Self::Item]) -> usize
269+
where
270+
R: Rng + ?Sized,
271+
{
272+
self.sample_fill(rng, buf)
273+
}
274+
275+
/// Deprecated: use [`Self::sample`] instead
276+
#[cfg(feature = "alloc")]
277+
#[deprecated(since = "0.9.2", note = "Renamed to `sample`")]
278+
fn choose_multiple<R>(self, rng: &mut R, amount: usize) -> Vec<Self::Item>
279+
where
280+
R: Rng + ?Sized,
281+
{
282+
self.sample(rng, amount)
283+
}
265284
}
266285

267286
impl<I> IteratorRandom for I where I: Iterator + Sized {}

src/seq/slice.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,45 @@ pub trait IndexedRandom: Index<usize> {
229229
.into_iter(),
230230
})
231231
}
232+
233+
/// Deprecated: use [`Self::sample`] instead
234+
#[cfg(feature = "alloc")]
235+
#[deprecated(since = "0.9.2", note = "Renamed to `sample`")]
236+
fn choose_multiple<R>(&self, rng: &mut R, amount: usize) -> SliceChooseIter<Self, Self::Output>
237+
where
238+
Self::Output: Sized,
239+
R: Rng + ?Sized,
240+
{
241+
self.sample(rng, amount)
242+
}
243+
244+
/// Deprecated: use [`Self::sample_array`] instead
245+
#[deprecated(since = "0.9.2", note = "Renamed to `sample_array`")]
246+
fn choose_multiple_array<R, const N: usize>(&self, rng: &mut R) -> Option<[Self::Output; N]>
247+
where
248+
Self::Output: Clone + Sized,
249+
R: Rng + ?Sized,
250+
{
251+
self.sample_array(rng)
252+
}
253+
254+
/// Deprecated: use [`Self::sample_weighted`] instead
255+
#[cfg(feature = "std")]
256+
#[deprecated(since = "0.9.2", note = "Renamed to `sample_weighted`")]
257+
fn choose_multiple_weighted<R, F, X>(
258+
&self,
259+
rng: &mut R,
260+
amount: usize,
261+
weight: F,
262+
) -> Result<SliceChooseIter<Self, Self::Output>, WeightError>
263+
where
264+
Self::Output: Sized,
265+
R: Rng + ?Sized,
266+
F: Fn(&Self::Output) -> X,
267+
X: Into<f64>,
268+
{
269+
self.sample_weighted(rng, amount, weight)
270+
}
232271
}
233272

234273
/// Extension trait on indexable lists, providing random sampling methods.

0 commit comments

Comments
 (0)