fix(core): compile on 32-bit targets (#8032)

This commit is contained in:
Lucas Fernandes Nogueira
2023-10-17 09:40:29 -03:00
committed by GitHub
parent a63e71f979
commit a5686e1507

View File

@@ -193,7 +193,12 @@ fn replace_csp_nonce(
) {
let mut nonces = Vec::new();
*asset = replace_with_callback(asset, token, || {
#[cfg(target_pointer_width = "64")]
let mut raw = [0u8; 8];
#[cfg(target_pointer_width = "32")]
let mut raw = [0u8; 4];
#[cfg(target_pointer_width = "16")]
let mut raw = [0u8; 2];
getrandom::getrandom(&mut raw).expect("failed to get random bytes");
let nonce = usize::from_ne_bytes(raw);
nonces.push(nonce);