Struct js_sys::JsString [−][src]
#[repr(transparent)]pub struct JsString { /* fields omitted */ }
Implementations
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn char_code_at(&self, index: u32) -> f64[src]
The charCodeAt() method returns an integer between 0 and 65535
representing the UTF-16 code unit at the given index (the UTF-16 code
unit matches the Unicode code point for code points representable in a
single UTF-16 code unit, but might also be the first code unit of a
surrogate pair for code points not representable in a single UTF-16 code
unit, e.g. Unicode code points > 0x10000). If you want the entire code
point value, use codePointAt().
Returns NaN if index is out of range.
impl JsString[src]
impl JsString[src]pub fn code_point_at(&self, pos: u32) -> JsValue[src]
The codePointAt() method returns a non-negative integer that is the
Unicode code point value.
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn from_char_code(char_codes: &[u16]) -> JsString[src]
The static String.fromCharCode() method returns a string created from
the specified sequence of UTF-16 code units.
Notes
There are a few bindings to from_char_code in js-sys: from_char_code1, from_char_code2, etc…
with different arities.
Additionally, this function accepts u16 for character codes, but
fixing others requires a breaking change release
(see https://github.com/rustwasm/wasm-bindgen/issues/1460 for details).
impl JsString[src]
impl JsString[src]pub fn from_char_code1(a: u32) -> JsString[src]
impl JsString[src]
impl JsString[src]pub fn from_char_code2(a: u32, b: u32) -> JsString[src]
impl JsString[src]
impl JsString[src]pub fn from_code_point(code_points: &[u32]) -> Result<JsString, JsValue>[src]
The static String.fromCodePoint() method returns a string created by
using the specified sequence of code points.
Exceptions
A RangeError is thrown if an invalid Unicode code point is given
Notes
There are a few bindings to from_code_point in js-sys: from_code_point1, from_code_point2, etc…
with different arities.
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn last_index_of(&self, search_value: &str, from_index: i32) -> i32[src]
The lastIndexOf() method returns the index within the calling String
object of the last occurrence of the specified value, searching
backwards from fromIndex. Returns -1 if the value is not found.
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn replace(&self, pattern: &str, replacement: &str) -> JsString[src]
The replace() method returns a new string with some or all matches of a pattern
replaced by a replacement. The pattern can be a string or a RegExp, and
the replacement can be a string or a function to be called for each match.
Note: The original string will remain unchanged.
impl JsString[src]
impl JsString[src]pub fn replace_with_function(
&self,
pattern: &str,
replacement: &Function
) -> JsString[src]
&self,
pattern: &str,
replacement: &Function
) -> JsString
impl JsString[src]
impl JsString[src]pub fn replace_by_pattern(
&self,
pattern: &RegExp,
replacement: &str
) -> JsString[src]
&self,
pattern: &RegExp,
replacement: &str
) -> JsString
impl JsString[src]
impl JsString[src]pub fn replace_by_pattern_with_function(
&self,
pattern: &RegExp,
replacement: &Function
) -> JsString[src]
&self,
pattern: &RegExp,
replacement: &Function
) -> JsString
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn split_limit(&self, separator: &str, limit: u32) -> Array[src]
impl JsString[src]
impl JsString[src]pub fn split_by_pattern(&self, pattern: &RegExp) -> Array[src]
impl JsString[src]
impl JsString[src]pub fn split_by_pattern_limit(&self, pattern: &RegExp, limit: u32) -> Array[src]
impl JsString[src]
impl JsString[src]pub fn starts_with(&self, search_string: &str, position: u32) -> bool[src]
The startsWith() method determines whether a string begins with the
characters of a specified string, returning true or false as
appropriate.
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn to_locale_lower_case(&self, locale: Option<&str>) -> JsString[src]
The toLocaleLowerCase() method returns the calling string value converted to lower case,
according to any locale-specific case mappings.
impl JsString[src]
impl JsString[src]pub fn to_locale_upper_case(&self, locale: Option<&str>) -> JsString[src]
The toLocaleUpperCase() method returns the calling string value converted to upper case,
according to any locale-specific case mappings.
impl JsString[src]
impl JsString[src]pub fn to_lower_case(&self) -> JsString[src]
The toLowerCase() method returns the calling string value
converted to lower case.
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn to_upper_case(&self) -> JsString[src]
The toUpperCase() method returns the calling string value converted to
uppercase (the value will be converted to a string if it isn’t one).
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn trim_right(&self) -> JsString[src]
The trimEnd() method removes whitespace from the end of a string.
trimRight() is an alias of this method.
impl JsString[src]
impl JsString[src]pub fn trim_start(&self) -> JsString[src]
The trimStart() method removes whitespace from the beginning of a
string. trimLeft() is an alias of this method.
impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]impl JsString[src]
impl JsString[src]pub fn raw_5(
call_site: &Object,
substitutions_1: &str,
substitutions_2: &str,
substitutions_3: &str,
substitutions_4: &str,
substitutions_5: &str
) -> Result<JsString, JsValue>[src]
call_site: &Object,
substitutions_1: &str,
substitutions_2: &str,
substitutions_3: &str,
substitutions_4: &str,
substitutions_5: &str
) -> Result<JsString, JsValue>
The static raw() method is a tag function of template literals,
similar to the r prefix in Python or the @ prefix in C# for string literals.
impl JsString[src]
impl JsString[src]pub fn raw_6(
call_site: &Object,
substitutions_1: &str,
substitutions_2: &str,
substitutions_3: &str,
substitutions_4: &str,
substitutions_5: &str,
substitutions_6: &str
) -> Result<JsString, JsValue>[src]
call_site: &Object,
substitutions_1: &str,
substitutions_2: &str,
substitutions_3: &str,
substitutions_4: &str,
substitutions_5: &str,
substitutions_6: &str
) -> Result<JsString, JsValue>
The static raw() method is a tag function of template literals,
similar to the r prefix in Python or the @ prefix in C# for string literals.
impl JsString[src]
impl JsString[src]pub fn raw_7(
call_site: &Object,
substitutions_1: &str,
substitutions_2: &str,
substitutions_3: &str,
substitutions_4: &str,
substitutions_5: &str,
substitutions_6: &str,
substitutions_7: &str
) -> Result<JsString, JsValue>[src]
call_site: &Object,
substitutions_1: &str,
substitutions_2: &str,
substitutions_3: &str,
substitutions_4: &str,
substitutions_5: &str,
substitutions_6: &str,
substitutions_7: &str
) -> Result<JsString, JsValue>
The static raw() method is a tag function of template literals,
similar to the r prefix in Python or the @ prefix in C# for string literals.
impl JsString[src]
impl JsString[src]pub fn try_from(val: &JsValue) -> Option<&JsString>[src]
recommended to use dyn_ref instead which is now equivalent
Returns the JsString value of this JS value if it’s an instance of a
string.
If this JS value is not an instance of a string then this returns
None.
pub fn is_valid_utf16(&self) -> bool[src]
Returns whether this string is a valid UTF-16 string.
This is useful for learning whether String::from(..) will return a
lossless representation of the JS string. If this string contains
unpaired surrogates then String::from will succeed but it will be a
lossy representation of the JS string because unpaired surrogates will
become replacement characters.
If this function returns false then to get a lossless representation
of the string you’ll need to manually use the iter method (or the
char_code_at accessor) to view the raw character codes.
For more information, see the documentation on JS strings vs Rust strings
pub fn iter<'a>(
&'a self
) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + 'a[src]
&'a self
) -> impl ExactSizeIterator<Item = u16> + DoubleEndedIterator<Item = u16> + 'a
Returns an iterator over the u16 character codes that make up this JS
string.
This method will call char_code_at for each code in this JS string,
returning an iterator of the codes in sequence.
pub fn as_char(&self) -> Option<char>[src]
If this string consists of a single Unicode code point, then this method
converts it into a Rust char without doing any allocations.
If this JS value is not a valid UTF-8 or consists of more than a single
codepoint, then this returns None.
Note that a single Unicode code point might be represented as more than
one code unit on the JavaScript side. For example, a JavaScript string
"\uD801\uDC37" is actually a single Unicode code point U+10437 which
corresponds to a character ‘𐐷’.
Methods from Deref<Target = Object>
pub fn constructor(&self) -> Function[src]
The constructor property returns a reference to the Object constructor
function that created the instance object.
pub fn has_own_property(&self, property: &JsValue) -> bool[src]
The hasOwnProperty() method returns a boolean indicating whether the
object has the specified property as its own property (as opposed to
inheriting it).
pub fn is_prototype_of(&self, value: &JsValue) -> bool[src]
The isPrototypeOf() method checks if an object exists in another
object’s prototype chain.
pub fn property_is_enumerable(&self, property: &JsValue) -> bool[src]
The propertyIsEnumerable() method returns a Boolean indicating
whether the specified property is enumerable.
pub fn to_locale_string(&self) -> JsString[src]
The toLocaleString() method returns a string representing the object.
This method is meant to be overridden by derived objects for
locale-specific purposes.
pub fn to_string(&self) -> JsString[src]
The toString() method returns a string representing the object.
pub fn value_of(&self) -> Object[src]
The valueOf() method returns the primitive value of the
specified object.
Trait Implementations
impl FromWasmAbi for JsString[src]
impl FromWasmAbi for JsString[src]impl IntoWasmAbi for JsString[src]
impl IntoWasmAbi for JsString[src]impl<'a> IntoWasmAbi for &'a JsString[src]
impl<'a> IntoWasmAbi for &'a JsString[src]impl JsCast for JsString[src]
impl JsCast for JsString[src]fn instanceof(val: &JsValue) -> bool[src]
fn is_type_of(val: &JsValue) -> bool[src]
fn unchecked_from_js(val: JsValue) -> Self[src]
fn unchecked_from_js_ref(val: &JsValue) -> &Self[src]
pub fn has_type<T>(&self) -> bool where
T: JsCast, [src]
T: JsCast,
pub fn dyn_into<T>(self) -> Result<T, Self> where
T: JsCast, [src]
T: JsCast,
pub fn dyn_ref<T>(&self) -> Option<&T> where
T: JsCast, [src]
T: JsCast,
pub fn unchecked_into<T>(self) -> T where
T: JsCast, [src]
T: JsCast,
pub fn unchecked_ref<T>(&self) -> &T where
T: JsCast, [src]
T: JsCast,
pub fn is_instance_of<T>(&self) -> bool where
T: JsCast, [src]
T: JsCast,
impl RefFromWasmAbi for JsString[src]
impl RefFromWasmAbi for JsString[src]type Abi = <JsValue as RefFromWasmAbi>::Abi
The wasm ABI type references to Self are recovered from.
type Anchor = ManuallyDrop<JsString>
The type that holds the reference to Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous. Read more
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor[src]
impl Eq for JsString[src]
impl StructuralEq for JsString[src]
impl StructuralPartialEq for JsString[src]
Auto Trait Implementations
impl RefUnwindSafe for JsString
impl !Send for JsString
impl !Sync for JsString
impl Unpin for JsString
impl UnwindSafe for JsString
Blanket Implementations
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi, [src]
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi, [src]type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi