Skip to content

Commit

Permalink
Implement From<NonNull<T>> for JsValue (rustwasm#3877)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed May 21, 2024
1 parent 4f59ace commit cd0195d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# `wasm-bindgen` Change Log
--------------------------------------------------------------------------------

## Unreleased

### Added

* Implement `From<NonNull<T>>` for `JsValue`.
[#3877](https://github.com/rustwasm/wasm-bindgen/pull/3877)

--------------------------------------------------------------------------------

## [0.2.92](https://github.com/rustwasm/wasm-bindgen/compare/0.2.91...0.2.92)

Released 2024-03-04
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use core::mem;
use core::ops::{
Add, BitAnd, BitOr, BitXor, Deref, DerefMut, Div, Mul, Neg, Not, Rem, Shl, Shr, Sub,
};
use core::ptr::NonNull;
use core::u32;

use crate::convert::{FromWasmAbi, TryFromJsValue, WasmRet, WasmSlice};
Expand Down Expand Up @@ -790,6 +791,13 @@ impl<T> From<*const T> for JsValue {
}
}

impl<T> From<NonNull<T>> for JsValue {
#[inline]
fn from(s: NonNull<T>) -> JsValue {
JsValue::from(s.as_ptr() as usize)
}
}

if_std! {
impl<'a> From<&'a String> for JsValue {
#[inline]
Expand Down

0 comments on commit cd0195d

Please sign in to comment.