pub struct JsStr<'a> { /* private fields */ }
Expand description
This is equivalent to Rust’s &str
.
Implementations§
Source§impl<'a> JsStr<'a>
impl<'a> JsStr<'a>
Sourcepub const fn latin1(value: &'a [u8]) -> Self
pub const fn latin1(value: &'a [u8]) -> Self
Creates a JsStr
from codepoints that can fit in a u8
.
Sourcepub const fn variant(self) -> JsStrVariant<'a>
pub const fn variant(self) -> JsStrVariant<'a>
Return the inner JsStrVariant
varient of the JsStr
.
Sourcepub fn trim_start(self) -> Self
pub fn trim_start(self) -> Self
Trims all leading space.
Sourcepub fn get<I>(self, index: I) -> Option<I::Value>where
I: JsSliceIndex<'a>,
pub fn get<I>(self, index: I) -> Option<I::Value>where
I: JsSliceIndex<'a>,
Returns an element or subslice depending on the type of index, otherwise None
.
Sourcepub unsafe fn get_unchecked<I>(self, index: I) -> I::Valuewhere
I: JsSliceIndex<'a>,
pub unsafe fn get_unchecked<I>(self, index: I) -> I::Valuewhere
I: JsSliceIndex<'a>,
Returns an element or subslice depending on the type of index, without doing bounds check.
§Safety
Caller must ensure the index is not out of bounds
Sourcepub fn starts_with(&self, needle: JsStr<'_>) -> bool
pub fn starts_with(&self, needle: JsStr<'_>) -> bool
Returns true if needle is a prefix of the JsStr
.
Trait Implementations§
Source§impl Ord for JsStr<'_>
impl Ord for JsStr<'_>
Source§impl PartialOrd for JsStr<'_>
impl PartialOrd for JsStr<'_>
impl<'a> Copy for JsStr<'a>
impl Eq for JsStr<'_>
Auto Trait Implementations§
impl<'a> Freeze for JsStr<'a>
impl<'a> RefUnwindSafe for JsStr<'a>
impl<'a> Send for JsStr<'a>
impl<'a> Sync for JsStr<'a>
impl<'a> Unpin for JsStr<'a>
impl<'a> UnwindSafe for JsStr<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more