mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed unsafe.
This commit is contained in:
parent
09525bf964
commit
cb4374160c
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -3174,6 +3174,7 @@ dependencies = [
|
|||||||
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"vek 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"vek 0.9.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"veloren-common 0.3.0",
|
"veloren-common 0.3.0",
|
||||||
|
"zerocopy 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3363,6 +3364,25 @@ name = "xml-rs"
|
|||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.2.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"zerocopy-derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
|
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
|
||||||
"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
|
"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5"
|
||||||
@ -3725,3 +3745,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum x11-dl 2.18.4 (registry+https://github.com/rust-lang/crates.io-index)" = "be65e1342a3baae65439cd03306778831a3d133b0d20243a7fb83fd5cf403c58"
|
"checksum x11-dl 2.18.4 (registry+https://github.com/rust-lang/crates.io-index)" = "be65e1342a3baae65439cd03306778831a3d133b0d20243a7fb83fd5cf403c58"
|
||||||
"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
|
"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
|
||||||
"checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5"
|
"checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5"
|
||||||
|
"checksum zerocopy 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "992b9b31f80fd4a167f903f879b8ca43d6716cc368ea01df90538baa2dd34056"
|
||||||
|
"checksum zerocopy-derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b090467ecd0624026e8a6405d343ac7382592530d54881330b3fc8e400280fa5"
|
||||||
|
@ -12,6 +12,7 @@ hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }
|
|||||||
lazy_static = "1.3.0"
|
lazy_static = "1.3.0"
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
rand_chacha = "0.2.1"
|
rand_chacha = "0.2.1"
|
||||||
|
zerocopy = "0.2.8"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
minifb = { git = "https://github.com/emoon/rust_minifb.git" }
|
minifb = { git = "https://github.com/emoon/rust_minifb.git" }
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use zerocopy::AsBytes;
|
||||||
|
|
||||||
/// Simple non-cryptographic diffusion function.
|
/// Simple non-cryptographic diffusion function.
|
||||||
pub fn diffuse(mut x: u32) -> u32 {
|
pub fn diffuse(mut x: u32) -> u32 {
|
||||||
x = x.wrapping_add(0x7ed55d16).wrapping_add(x << 12);
|
x = x.wrapping_add(0x7ed55d16).wrapping_add(x << 12);
|
||||||
@ -16,5 +18,8 @@ pub fn rng_state(mut x: u32) -> [u8; 32] {
|
|||||||
x = diffuse(x);
|
x = diffuse(x);
|
||||||
*s = x;
|
*s = x;
|
||||||
}
|
}
|
||||||
unsafe { std::mem::transmute(r) }
|
let bytes = r.as_bytes();
|
||||||
|
let mut a: [u8; 32] = [0; 32];
|
||||||
|
a.copy_from_slice(bytes);
|
||||||
|
a
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user