1use {js_sys::JsString, wasm_bindgen::JsValue};
2
3pub trait ToStringValue {
5 type Js: AsRef<JsValue>;
6 fn to_string_value(self) -> Self::Js;
7}
8
9impl ToStringValue for JsString {
10 type Js = JsValue;
11
12 #[inline]
13 fn to_string_value(self) -> Self::Js {
14 JsValue::from(self)
15 }
16}
17
18impl<'str> ToStringValue for &'str JsString {
19 type Js = &'str JsValue;
20
21 #[inline]
22 fn to_string_value(self) -> Self::Js {
23 self
24 }
25}
26
27impl ToStringValue for String {
28 type Js = JsValue;
29
30 #[inline]
31 fn to_string_value(self) -> Self::Js {
32 (&self).to_string_value()
33 }
34}
35
36impl ToStringValue for &String {
37 type Js = JsValue;
38
39 #[inline]
40 fn to_string_value(self) -> Self::Js {
41 JsValue::from(self)
42 }
43}
44
45impl ToStringValue for &str {
46 type Js = JsValue;
47
48 #[inline]
49 fn to_string_value(self) -> Self::Js {
50 JsValue::from(self)
51 }
52}