Skip to content

Commit 0551b99

Browse files
committed
v3.0.0: Bump to rand 0.9
1 parent fe12e5e commit 0551b99

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[package]
22
name = "mt19937"
3-
version = "2.0.1"
3+
version = "3.0.0"
44
authors = ["Noa <coolreader18@gmail.com>", "RustPython Team"]
5-
edition = "2018"
5+
edition = "2021"
66
license-file = "LICENSE"
77
description = "A translation of the MT19937 Mersenne Twister rng algorithm to Rust"
88
documentation = "https://docs.rs/mt19937"
99
repository = "https://github.com/RustPython/mt19937"
10+
rust-version = "1.63"
1011

1112
[dependencies]
12-
rand_core = "0.6"
13+
rand_core = "0.9"

src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,23 +246,26 @@ impl rand_core::RngCore for MT19937 {
246246
fn fill_bytes(&mut self, dest: &mut [u8]) {
247247
rand_core::impls::fill_bytes_via_next(self, dest)
248248
}
249-
#[inline]
250-
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
251-
self.fill_bytes(dest);
252-
Ok(())
253-
}
254249
}
255250

256251
/// Seed for <MT19937 as rand_core::SeedableRng>
257252
///
258253
/// Very big seed, but this is the size that CPython uses as well
254+
#[derive(Clone, Copy)]
259255
pub struct Seed(pub [u32; N]);
260256
impl Default for Seed {
261257
#[inline]
262258
fn default() -> Self {
263259
Seed([0; N])
264260
}
265261
}
262+
impl AsRef<[u8]> for Seed {
263+
#[inline]
264+
fn as_ref(&self) -> &[u8] {
265+
// this will always get the full bytes, since align_of(u32) > align_of(u8)
266+
unsafe { self.0.align_to().1 }
267+
}
268+
}
266269
impl AsMut<[u8]> for Seed {
267270
#[inline]
268271
fn as_mut(&mut self) -> &mut [u8] {

0 commit comments

Comments
 (0)