Struct include_js_core::JSStr [−][src]
#[repr(transparent)]pub struct JSStr { /* fields omitted */ }
Expand description
Wrapper around str
that ensures it contains syntactically valid Javascript.
This is the borrowed version of JSString
so &JSStr
is to JSString
what &str
is to String
Implementations
Checks if the content of js
is syntactically valid Javascript before
coersing it to &JSStr
Examples
use include_js::JSStr;
let js_str = JSStr::new("function f() {}");
assert!(js_str.is_ok());
use include_js::JSStr;
let js_str = JSStr::new("#include <vector>");
assert!(js_str.is_err());
Coerses js
directly into a &JSStr
without checking for validity