diff --git a/src/wasi.rs b/src/wasi.rs index 82d3f37c..ef47b18b 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -28,9 +28,12 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { let ret = unsafe { random_get(dest.as_mut_ptr() as i32, dest.len() as i32) }; match ret { 0 => Ok(()), - code => u32::try_from(code) - .map(Error::from_os_error) - .unwrap_or(Error::UNEXPECTED), + code => { + let err = u32::try_from(code) + .map(Error::from_os_error) + .unwrap_or(Error::UNEXPECTED); + Err(err) + } } }