wiwi_wasm/
any.rs

1// todo this file is incomplete
2
3use wasm_bindgen::JsValue;
4
5#[repr(transparent)]
6pub struct ExternAny {
7	inner: JsValue
8}
9
10impl ExternAny {
11	#[inline]
12	pub fn from_js_value(value: JsValue) -> Self {
13		Self { inner: value }
14	}
15
16	#[inline]
17	pub fn from_js_value_ref(value: &JsValue) -> &Self {
18		// SAFETY: ExternAny is repr(transparent) over JsValue
19		unsafe { &*(&raw const *value).cast::<ExternAny>() }
20	}
21
22	#[inline]
23	pub fn as_js_value(&self) -> &JsValue {
24		&self.inner
25	}
26
27	#[inline]
28	pub fn into_js_value(self) -> JsValue {
29		self.inner
30	}
31
32	#[inline]
33	#[expect(
34		clippy::should_implement_trait,
35		reason = "shshshhshhshhshsh"
36	)]
37	pub fn from_str(s: &str) -> Self {
38		Self::from_js_value(JsValue::from_str(s))
39	}
40
41	// todo return string
42	#[inline]
43	pub fn do_typeof(&self) -> Self {
44		Self::from_js_value(self.as_js_value().js_typeof())
45	}
46}