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

Converts the &JSStr back into an &str, this should be a noop.

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Immutably borrows from an owned value. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more