Update Panic documentation and #[track_caller] (#1447)
This is stuff I missed in #1442 Signed-off-by: Joe Richey <joerichey@google.com> Co-authored-by: Diggory Hardy <git@dhardy.name>
This commit is contained in:
parent
fba5521f0f
commit
e93776960e
@ -13,7 +13,7 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
|
||||
- Bump the MSRV to 1.61.0
|
||||
- Rename `Rng::gen` to `Rng::random` to avoid conflict with the new `gen` keyword in Rust 2024 (#1435)
|
||||
- Move all benchmarks to new `benches` crate (#1439)
|
||||
- Annotate panicking methods with `#[track_caller]` (#1442)
|
||||
- Annotate panicking methods with `#[track_caller]` (#1442, #1447)
|
||||
|
||||
## [0.9.0-alpha.1] - 2024-03-18
|
||||
- Add the `Slice::num_choices` method to the Slice distribution (#1402)
|
||||
|
@ -12,7 +12,12 @@
|
||||
//! useful functions available.
|
||||
|
||||
/// Reads unsigned 32 bit integers from `src` into `dst`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If `dst` has insufficent space (`4*dst.len() < src.len()`).
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn read_u32_into(src: &[u8], dst: &mut [u32]) {
|
||||
assert!(src.len() >= 4 * dst.len());
|
||||
for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(4)) {
|
||||
@ -21,7 +26,12 @@ pub fn read_u32_into(src: &[u8], dst: &mut [u32]) {
|
||||
}
|
||||
|
||||
/// Reads unsigned 64 bit integers from `src` into `dst`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If `dst` has insufficent space (`8*dst.len() < src.len()`).
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn read_u64_into(src: &[u8], dst: &mut [u64]) {
|
||||
assert!(src.len() >= 8 * dst.len());
|
||||
for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(8)) {
|
||||
|
@ -438,7 +438,6 @@ pub trait SeedableRng: Sized {
|
||||
/// [`try_from_os_rng`]: SeedableRng::try_from_os_rng
|
||||
#[cfg(feature = "getrandom")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))]
|
||||
#[track_caller]
|
||||
fn from_os_rng() -> Self {
|
||||
match Self::try_from_os_rng() {
|
||||
Ok(res) => res,
|
||||
|
@ -290,6 +290,7 @@ impl<W: Clone + PartialEq + PartialOrd + SampleUniform + SubAssign<W> + Weight>
|
||||
impl<W: Clone + PartialEq + PartialOrd + SampleUniform + SubAssign<W> + Weight> Distribution<usize>
|
||||
for WeightedTreeIndex<W>
|
||||
{
|
||||
#[track_caller]
|
||||
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize {
|
||||
self.try_sample(rng).unwrap()
|
||||
}
|
||||
|
@ -219,6 +219,7 @@ impl ExactSizeIterator for IndexVecIntoIter {}
|
||||
/// to adapt the internal `sample_floyd` implementation.
|
||||
///
|
||||
/// Panics if `amount > length`.
|
||||
#[track_caller]
|
||||
pub fn sample<R>(rng: &mut R, length: usize, amount: usize) -> IndexVec
|
||||
where R: Rng + ?Sized {
|
||||
if amount > length {
|
||||
|
Loading…
x
Reference in New Issue
Block a user