Skip to content

Commit

Permalink
add safety comments to the by-ref transmute for non-zero nums
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Apr 20, 2022
1 parent bb111eb commit 6c0a24c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/kv/value.rs
Expand Up @@ -485,12 +485,14 @@ impl<'v> From<&'v i128> for Value<'v> {

impl<'v> From<&'v std::num::NonZeroU128> for Value<'v> {
fn from(v: &'v std::num::NonZeroU128) -> Value<'v> {
// SAFETY: `NonZeroU128` and `u128` have the same ABI
Value::from_value_bag(unsafe { std::mem::transmute::<&std::num::NonZeroU128, &u128>(v) })
}
}

impl<'v> From<&'v std::num::NonZeroI128> for Value<'v> {
fn from(v: &'v std::num::NonZeroI128) -> Value<'v> {
// SAFETY: `NonZeroI128` and `i128` have the same ABI
Value::from_value_bag(unsafe { std::mem::transmute::<&std::num::NonZeroI128, &i128>(v) })
}
}
Expand Down

0 comments on commit 6c0a24c

Please sign in to comment.