pub trait ToJsValue {
// Required method
fn to_js_value(&self) -> String;
}Expand description
A trait for converting Rust types to JavaScript value representations.
Types that implement this trait can be used in js! macro interpolation.
§Examples
use viewpoint_js_core::ToJsValue;
assert_eq!(42.to_js_value(), "42");
assert_eq!(true.to_js_value(), "true");
assert_eq!("hello".to_js_value(), r#""hello""#);Required Methods§
Sourcefn to_js_value(&self) -> String
fn to_js_value(&self) -> String
Convert this value to a JavaScript representation.
The returned string should be valid JavaScript that represents this value. For example:
- Integers:
"42" - Strings:
"\"hello\"" - Booleans:
"true"or"false" - null:
"null"