(function() { var type_impls = Object.fromEntries([["jsonpath_rust",[["
1.0.0 · Source§

impl Add<&str> for String

Implements the + operator for concatenating two strings.

\n

This consumes the String on the left-hand side and re-uses its buffer (growing it if\nnecessary). This is done to avoid allocating a new String and copying the entire contents on\nevery operation, which would lead to O(n^2) running time when building an n-byte string by\nrepeated concatenation.

\n

The string on the right-hand side is only borrowed; its contents are copied into the returned\nString.

\n

§Examples

\n

Concatenating two Strings takes the first by value and borrows the second:

\n\n
let a = String::from(\"hello\");\nlet b = String::from(\" world\");\nlet c = a + &b;\n// `a` is moved and can no longer be used here.
\n

If you want to keep using the first String, you can clone it and append to the clone instead:

\n\n
let a = String::from(\"hello\");\nlet b = String::from(\" world\");\nlet c = a.clone() + &b;\n// `a` is still valid here.
\n

Concatenating &str slices can be done by converting the first to a String:

\n\n
let a = \"hello\";\nlet b = \" world\";\nlet c = a.to_string() + b;
Source§

type Output = String

The resulting type after applying the + operator.
Source§

fn add(self, other: &str) -> String

Performs the + operation. Read more
","Add<&str>","jsonpath_rust::query::QueryPath"],["
1.12.0 · Source§

impl AddAssign<&str> for String

Implements the += operator for appending to a String.

\n

This has the same behavior as the push_str method.

\n
Source§

fn add_assign(&mut self, other: &str)

Performs the += operation. Read more
","AddAssign<&str>","jsonpath_rust::query::QueryPath"],["
1.43.0 · Source§

impl AsMut<str> for String

Source§

fn as_mut(&mut self) -> &mut str

Converts this type into a mutable reference of the (usually inferred) input type.
","AsMut","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl AsRef<[u8]> for String

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
","AsRef<[u8]>","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl AsRef<OsStr> for String

Source§

fn as_ref(&self) -> &OsStr

Converts this type into a shared reference of the (usually inferred) input type.
","AsRef","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl AsRef<Path> for String

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
","AsRef","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl AsRef<str> for String

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
","AsRef","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Borrow<str> for String

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
","Borrow","jsonpath_rust::query::QueryPath"],["
1.36.0 · Source§

impl BorrowMut<str> for String

Source§

fn borrow_mut(&mut self) -> &mut str

Mutably borrows from an owned value. Read more
","BorrowMut","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Clone for String

Source§

fn clone_from(&mut self, source: &String)

Clones the contents of source into self.

\n

This method is preferred over simply assigning source.clone() to self,\nas it avoids reallocation if possible.

\n
Source§

fn clone(&self) -> String

Returns a duplicate of the value. Read more
","Clone","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Debug for String

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
","Debug","jsonpath_rust::query::QueryPath"],["
1.0.0 (const: unstable) · Source§

impl Default for String

Source§

fn default() -> String

Creates an empty String.

\n
","Default","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Deref for String

Source§

type Target = str

The resulting type after dereferencing.
Source§

fn deref(&self) -> &str

Dereferences the value.
","Deref","jsonpath_rust::query::QueryPath"],["
1.3.0 · Source§

impl DerefMut for String

Source§

fn deref_mut(&mut self) -> &mut str

Mutably dereferences the value.
","DerefMut","jsonpath_rust::query::QueryPath"],["
Source§

impl<'de> Deserialize<'de> for String

Source§

fn deserialize<D>(\n deserializer: D,\n) -> Result<String, <D as Deserializer<'de>>::Error>
where\n D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
","Deserialize<'de>","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Display for String

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
","Display","jsonpath_rust::query::QueryPath"],["
Source§

impl<'a> Extend<&'a AsciiChar> for String

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = &'a AsciiChar>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, c: &'a AsciiChar)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend<&'a AsciiChar>","jsonpath_rust::query::QueryPath"],["
1.2.0 · Source§

impl<'a> Extend<&'a char> for String

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = &'a char>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, _: &'a char)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend<&'a char>","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl<'a> Extend<&'a str> for String

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = &'a str>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, s: &'a str)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend<&'a str>","jsonpath_rust::query::QueryPath"],["
1.45.0 · Source§

impl<A> Extend<Box<str, A>> for String
where\n A: Allocator,

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = Box<str, A>>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend>","jsonpath_rust::query::QueryPath"],["
Source§

impl Extend<AsciiChar> for String

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = AsciiChar>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, c: AsciiChar)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend","jsonpath_rust::query::QueryPath"],["
1.19.0 · Source§

impl<'a> Extend<Cow<'a, str>> for String

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = Cow<'a, str>>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, s: Cow<'a, str>)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend>","jsonpath_rust::query::QueryPath"],["
1.4.0 · Source§

impl Extend<String> for String

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = String>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, s: String)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Extend<char> for String

Source§

fn extend<I>(&mut self, iter: I)
where\n I: IntoIterator<Item = char>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, c: char)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
","Extend","jsonpath_rust::query::QueryPath"],["
1.35.0 · Source§

impl From<&String> for String

Source§

fn from(s: &String) -> String

Converts a &String into a String.

\n

This clones s and returns the clone.

\n
","From<&String>","jsonpath_rust::query::QueryPath"],["
1.44.0 · Source§

impl From<&mut str> for String

Source§

fn from(s: &mut str) -> String

Converts a &mut str into a String.

\n

The result is allocated on the heap.

\n
","From<&mut str>","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl From<&str> for String

Source§

fn from(s: &str) -> String

Converts a &str into a String.

\n

The result is allocated on the heap.

\n
","From<&str>","jsonpath_rust::query::QueryPath"],["
1.18.0 · Source§

impl From<Box<str>> for String

Source§

fn from(s: Box<str>) -> String

Converts the given boxed str slice to a String.\nIt is notable that the str slice is owned.

\n
§Examples
\n
let s1: String = String::from(\"hello world\");\nlet s2: Box<str> = s1.into_boxed_str();\nlet s3: String = String::from(s2);\n\nassert_eq!(\"hello world\", s3)
","From>","jsonpath_rust::query::QueryPath"],["
1.14.0 · Source§

impl<'a> From<Cow<'a, str>> for String

Source§

fn from(s: Cow<'a, str>) -> String

Converts a clone-on-write string to an owned\ninstance of String.

\n

This extracts the owned string,\nclones the string if it is not already owned.

\n
§Example
\n
// If the string is not owned...\nlet cow: Cow<'_, str> = Cow::Borrowed(\"eggplant\");\n// It will allocate on the heap and copy the string.\nlet owned: String = String::from(cow);\nassert_eq!(&owned[..], \"eggplant\");
","From>","jsonpath_rust::query::QueryPath"],["
1.46.0 · Source§

impl From<char> for String

Source§

fn from(c: char) -> String

Allocates an owned String from a single character.

\n
§Example
\n
let c: char = 'a';\nlet s: String = String::from(c);\nassert_eq!(\"a\", &s[..]);
","From","jsonpath_rust::query::QueryPath"],["
1.17.0 · Source§

impl<'a> FromIterator<&'a char> for String

Source§

fn from_iter<I>(iter: I) -> String
where\n I: IntoIterator<Item = &'a char>,

Creates a value from an iterator. Read more
","FromIterator<&'a char>","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl<'a> FromIterator<&'a str> for String

Source§

fn from_iter<I>(iter: I) -> String
where\n I: IntoIterator<Item = &'a str>,

Creates a value from an iterator. Read more
","FromIterator<&'a str>","jsonpath_rust::query::QueryPath"],["
1.45.0 · Source§

impl<A> FromIterator<Box<str, A>> for String
where\n A: Allocator,

Source§

fn from_iter<I>(iter: I) -> String
where\n I: IntoIterator<Item = Box<str, A>>,

Creates a value from an iterator. Read more
","FromIterator>","jsonpath_rust::query::QueryPath"],["
1.19.0 · Source§

impl<'a> FromIterator<Cow<'a, str>> for String

Source§

fn from_iter<I>(iter: I) -> String
where\n I: IntoIterator<Item = Cow<'a, str>>,

Creates a value from an iterator. Read more
","FromIterator>","jsonpath_rust::query::QueryPath"],["
1.4.0 · Source§

impl FromIterator<String> for String

Source§

fn from_iter<I>(iter: I) -> String
where\n I: IntoIterator<Item = String>,

Creates a value from an iterator. Read more
","FromIterator","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl FromIterator<char> for String

Source§

fn from_iter<I>(iter: I) -> String
where\n I: IntoIterator<Item = char>,

Creates a value from an iterator. Read more
","FromIterator","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl FromStr for String

Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<String, <String as FromStr>::Err>

Parses a string s to return a value of this type. Read more
","FromStr","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Hash for String

Source§

fn hash<H>(&self, hasher: &mut H)
where\n H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where\n H: Hasher,\n Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
","Hash","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl<I> Index<I> for String
where\n I: SliceIndex<str>,

Source§

type Output = <I as SliceIndex<str>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &<I as SliceIndex<str>>::Output

Performs the indexing (container[index]) operation. Read more
","Index","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl<I> IndexMut<I> for String
where\n I: SliceIndex<str>,

Source§

fn index_mut(&mut self, index: I) -> &mut <I as SliceIndex<str>>::Output

Performs the mutable indexing (container[index]) operation. Read more
","IndexMut","jsonpath_rust::query::QueryPath"],["
Source§

impl<'de, E> IntoDeserializer<'de, E> for String
where\n E: Error,

Source§

type Deserializer = StringDeserializer<E>

The type of the deserializer being converted into.
Source§

fn into_deserializer(self) -> StringDeserializer<E>

Convert this value into a deserializer.
","IntoDeserializer<'de, E>","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Ord for String

Source§

fn cmp(&self, other: &String) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where\n Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where\n Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where\n Self: Sized,

Restrict a value to a certain interval. Read more
","Ord","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl<'a, 'b> PartialEq<&'a str> for String

Source§

fn eq(&self, other: &&'a str) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &&'a str) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq<&'a str>","jsonpath_rust::query::QueryPath"],["
Source§

impl<'a> PartialEq<ByteStr> for String

Source§

fn eq(&self, other: &ByteStr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","jsonpath_rust::query::QueryPath"],["
Source§

impl<'a> PartialEq<ByteString> for String

Source§

fn eq(&self, other: &ByteString) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl<'a, 'b> PartialEq<Cow<'a, str>> for String

Source§

fn eq(&self, other: &Cow<'a, str>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &Cow<'a, str>) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq>","jsonpath_rust::query::QueryPath"],["
1.91.0 · Source§

impl PartialEq<Path> for String

Source§

fn eq(&self, other: &Path) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","jsonpath_rust::query::QueryPath"],["
1.91.0 · Source§

impl PartialEq<PathBuf> for String

Source§

fn eq(&self, other: &PathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","jsonpath_rust::query::QueryPath"],["
Source§

impl PartialEq<Value> for String

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl<'a, 'b> PartialEq<str> for String

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &str) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl PartialEq for String

Source§

fn eq(&self, other: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl PartialOrd for String

Source§

fn partial_cmp(&self, other: &String) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the\n<= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the >\noperator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by\nthe >= operator. Read more
","PartialOrd","jsonpath_rust::query::QueryPath"],["
Source§

impl Replacer for String

Source§

fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String)

Appends possibly empty data to dst to replace the current match. Read more
Source§

fn no_expansion(&mut self) -> Option<Cow<'_, str>>

Return a fixed unchanging replacement string. Read more
Source§

fn by_ref<'r>(&'r mut self) -> ReplacerRef<'r, Self>

Returns a type that implements Replacer, but that borrows and wraps\nthis Replacer. Read more
","Replacer","jsonpath_rust::query::QueryPath"],["
Source§

impl Serialize for String

Source§

fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where\n S: Serializer,

Serialize this value into the given Serde serializer. Read more
","Serialize","jsonpath_rust::query::QueryPath"],["
Source§

impl String

1.0.0 (const: 1.39.0) · Source

pub const fn new() -> String

Creates a new empty String.

\n

Given that the String is empty, this will not allocate any initial\nbuffer. While that means that this initial operation is very\ninexpensive, it may cause excessive allocation later when you add\ndata. If you have an idea of how much data the String will hold,\nconsider the with_capacity method to prevent excessive\nre-allocation.

\n
§Examples
\n
let s = String::new();
1.0.0 · Source

pub fn with_capacity(capacity: usize) -> String

Creates a new empty String with at least the specified capacity.

\n

Strings have an internal buffer to hold their data. The capacity is\nthe length of that buffer, and can be queried with the capacity\nmethod. This method creates an empty String, but one with an initial\nbuffer that can hold at least capacity bytes. This is useful when you\nmay be appending a bunch of data to the String, reducing the number of\nreallocations it needs to do.

\n

If the given capacity is 0, no allocation will occur, and this method\nis identical to the new method.

\n
§Examples
\n
let mut s = String::with_capacity(10);\n\n// The String contains no chars, even though it has capacity for more\nassert_eq!(s.len(), 0);\n\n// These are all done without reallocating...\nlet cap = s.capacity();\nfor _ in 0..10 {\n    s.push('a');\n}\n\nassert_eq!(s.capacity(), cap);\n\n// ...but this may make the string reallocate\ns.push('a');
Source

pub fn try_with_capacity(capacity: usize) -> Result<String, TryReserveError>

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

Creates a new empty String with at least the specified capacity.

\n
§Errors
\n

Returns Err if the capacity exceeds isize::MAX bytes,\nor if the memory allocator reports failure.

\n
1.0.0 · Source

pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error>

Converts a vector of bytes to a String.

\n

A string (String) is made of bytes (u8), and a vector of bytes\n(Vec<u8>) is made of bytes, so this function converts between the\ntwo. Not all byte slices are valid Strings, however: String\nrequires that it is valid UTF-8. from_utf8() checks to ensure that\nthe bytes are valid UTF-8, and then does the conversion.

\n

If you are sure that the byte slice is valid UTF-8, and you don’t want\nto incur the overhead of the validity check, there is an unsafe version\nof this function, from_utf8_unchecked, which has the same behavior\nbut skips the check.

\n

This method will take care to not copy the vector, for efficiency’s\nsake.

\n

If you need a &str instead of a String, consider\nstr::from_utf8.

\n

The inverse of this method is into_bytes.

\n
§Errors
\n

Returns Err if the slice is not UTF-8 with a description as to why the\nprovided bytes are not UTF-8. The vector you moved in is also included.

\n
§Examples
\n

Basic usage:

\n\n
// some bytes, in a vector\nlet sparkle_heart = vec![240, 159, 146, 150];\n\n// We know these bytes are valid, so we'll use `unwrap()`.\nlet sparkle_heart = String::from_utf8(sparkle_heart).unwrap();\n\nassert_eq!(\"💖\", sparkle_heart);
\n

Incorrect bytes:

\n\n
// some invalid bytes, in a vector\nlet sparkle_heart = vec![0, 159, 146, 150];\n\nassert!(String::from_utf8(sparkle_heart).is_err());
\n

See the docs for FromUtf8Error for more details on what you can do\nwith this error.

\n
1.0.0 · Source

pub fn from_utf8_lossy(v: &[u8]) -> Cow<'_, str>

Converts a slice of bytes to a string, including invalid characters.

\n

Strings are made of bytes (u8), and a slice of bytes\n(&[u8]) is made of bytes, so this function converts\nbetween the two. Not all byte slices are valid strings, however: strings\nare required to be valid UTF-8. During this conversion,\nfrom_utf8_lossy() will replace any invalid UTF-8 sequences with\nU+FFFD REPLACEMENT CHARACTER, which looks like this: �

\n

If you are sure that the byte slice is valid UTF-8, and you don’t want\nto incur the overhead of the conversion, there is an unsafe version\nof this function, from_utf8_unchecked, which has the same behavior\nbut skips the checks.

\n

This function returns a Cow<'a, str>. If our byte slice is invalid\nUTF-8, then we need to insert the replacement characters, which will\nchange the size of the string, and hence, require a String. But if\nit’s already valid UTF-8, we don’t need a new allocation. This return\ntype allows us to handle both cases.

\n
§Examples
\n

Basic usage:

\n\n
// some bytes, in a vector\nlet sparkle_heart = vec![240, 159, 146, 150];\n\nlet sparkle_heart = String::from_utf8_lossy(&sparkle_heart);\n\nassert_eq!(\"💖\", sparkle_heart);
\n

Incorrect bytes:

\n\n
// some invalid bytes\nlet input = b\"Hello \\xF0\\x90\\x80World\";\nlet output = String::from_utf8_lossy(input);\n\nassert_eq!(\"Hello �World\", output);
Source

pub fn from_utf8_lossy_owned(v: Vec<u8>) -> String

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

Converts a Vec<u8> to a String, substituting invalid UTF-8\nsequences with replacement characters.

\n

See from_utf8_lossy for more details.

\n

Note that this function does not guarantee reuse of the original Vec\nallocation.

\n
§Examples
\n

Basic usage:

\n\n
#![feature(string_from_utf8_lossy_owned)]\n// some bytes, in a vector\nlet sparkle_heart = vec![240, 159, 146, 150];\n\nlet sparkle_heart = String::from_utf8_lossy_owned(sparkle_heart);\n\nassert_eq!(String::from(\"💖\"), sparkle_heart);
\n

Incorrect bytes:

\n\n
#![feature(string_from_utf8_lossy_owned)]\n// some invalid bytes\nlet input: Vec<u8> = b\"Hello \\xF0\\x90\\x80World\".into();\nlet output = String::from_utf8_lossy_owned(input);\n\nassert_eq!(String::from(\"Hello �World\"), output);
1.0.0 · Source

pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error>

Decode a native endian UTF-16–encoded vector v into a String,\nreturning Err if v contains any invalid data.

\n
§Examples
\n
// 𝄞music\nlet v = &[0xD834, 0xDD1E, 0x006d, 0x0075,\n          0x0073, 0x0069, 0x0063];\nassert_eq!(String::from(\"𝄞music\"),\n           String::from_utf16(v).unwrap());\n\n// 𝄞mu<invalid>ic\nlet v = &[0xD834, 0xDD1E, 0x006d, 0x0075,\n          0xD800, 0x0069, 0x0063];\nassert!(String::from_utf16(v).is_err());
1.0.0 · Source

pub fn from_utf16_lossy(v: &[u16]) -> String

Decode a native endian UTF-16–encoded slice v into a String,\nreplacing invalid data with the replacement character (U+FFFD).

\n

Unlike from_utf8_lossy which returns a Cow<'a, str>,\nfrom_utf16_lossy returns a String since the UTF-16 to UTF-8\nconversion requires a memory allocation.

\n
§Examples
\n
// 𝄞mus<invalid>ic<invalid>\nlet v = &[0xD834, 0xDD1E, 0x006d, 0x0075,\n          0x0073, 0xDD1E, 0x0069, 0x0063,\n          0xD834];\n\nassert_eq!(String::from(\"𝄞mus\\u{FFFD}ic\\u{FFFD}\"),\n           String::from_utf16_lossy(v));
Source

pub fn from_utf16le(v: &[u8]) -> Result<String, FromUtf16Error>

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

Decode a UTF-16LE–encoded vector v into a String,\nreturning Err if v contains any invalid data.

\n
§Examples
\n

Basic usage:

\n\n
#![feature(str_from_utf16_endian)]\n// 𝄞music\nlet v = &[0x34, 0xD8, 0x1E, 0xDD, 0x6d, 0x00, 0x75, 0x00,\n          0x73, 0x00, 0x69, 0x00, 0x63, 0x00];\nassert_eq!(String::from(\"𝄞music\"),\n           String::from_utf16le(v).unwrap());\n\n// 𝄞mu<invalid>ic\nlet v = &[0x34, 0xD8, 0x1E, 0xDD, 0x6d, 0x00, 0x75, 0x00,\n          0x00, 0xD8, 0x69, 0x00, 0x63, 0x00];\nassert!(String::from_utf16le(v).is_err());
Source

pub fn from_utf16le_lossy(v: &[u8]) -> String

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

Decode a UTF-16LE–encoded slice v into a String, replacing\ninvalid data with the replacement character (U+FFFD).

\n

Unlike from_utf8_lossy which returns a Cow<'a, str>,\nfrom_utf16le_lossy returns a String since the UTF-16 to UTF-8\nconversion requires a memory allocation.

\n
§Examples
\n

Basic usage:

\n\n
#![feature(str_from_utf16_endian)]\n// 𝄞mus<invalid>ic<invalid>\nlet v = &[0x34, 0xD8, 0x1E, 0xDD, 0x6d, 0x00, 0x75, 0x00,\n          0x73, 0x00, 0x1E, 0xDD, 0x69, 0x00, 0x63, 0x00,\n          0x34, 0xD8];\n\nassert_eq!(String::from(\"𝄞mus\\u{FFFD}ic\\u{FFFD}\"),\n           String::from_utf16le_lossy(v));
Source

pub fn from_utf16be(v: &[u8]) -> Result<String, FromUtf16Error>

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

Decode a UTF-16BE–encoded vector v into a String,\nreturning Err if v contains any invalid data.

\n
§Examples
\n

Basic usage:

\n\n
#![feature(str_from_utf16_endian)]\n// 𝄞music\nlet v = &[0xD8, 0x34, 0xDD, 0x1E, 0x00, 0x6d, 0x00, 0x75,\n          0x00, 0x73, 0x00, 0x69, 0x00, 0x63];\nassert_eq!(String::from(\"𝄞music\"),\n           String::from_utf16be(v).unwrap());\n\n// 𝄞mu<invalid>ic\nlet v = &[0xD8, 0x34, 0xDD, 0x1E, 0x00, 0x6d, 0x00, 0x75,\n          0xD8, 0x00, 0x00, 0x69, 0x00, 0x63];\nassert!(String::from_utf16be(v).is_err());
Source

pub fn from_utf16be_lossy(v: &[u8]) -> String

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

Decode a UTF-16BE–encoded slice v into a String, replacing\ninvalid data with the replacement character (U+FFFD).

\n

Unlike from_utf8_lossy which returns a Cow<'a, str>,\nfrom_utf16le_lossy returns a String since the UTF-16 to UTF-8\nconversion requires a memory allocation.

\n
§Examples
\n

Basic usage:

\n\n
#![feature(str_from_utf16_endian)]\n// 𝄞mus<invalid>ic<invalid>\nlet v = &[0xD8, 0x34, 0xDD, 0x1E, 0x00, 0x6d, 0x00, 0x75,\n          0x00, 0x73, 0xDD, 0x1E, 0x00, 0x69, 0x00, 0x63,\n          0xD8, 0x34];\n\nassert_eq!(String::from(\"𝄞mus\\u{FFFD}ic\\u{FFFD}\"),\n           String::from_utf16be_lossy(v));
Source

pub fn into_raw_parts(self) -> (*mut u8, usize, usize)

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

Decomposes a String into its raw components: (pointer, length, capacity).

\n

Returns the raw pointer to the underlying data, the length of\nthe string (in bytes), and the allocated capacity of the data\n(in bytes). These are the same arguments in the same order as\nthe arguments to from_raw_parts.

\n

After calling this function, the caller is responsible for the\nmemory previously managed by the String. The only way to do\nthis is to convert the raw pointer, length, and capacity back\ninto a String with the from_raw_parts function, allowing\nthe destructor to perform the cleanup.

\n
§Examples
\n
#![feature(vec_into_raw_parts)]\nlet s = String::from(\"hello\");\n\nlet (ptr, len, cap) = s.into_raw_parts();\n\nlet rebuilt = unsafe { String::from_raw_parts(ptr, len, cap) };\nassert_eq!(rebuilt, \"hello\");
1.0.0 · Source

pub unsafe fn from_raw_parts(\n buf: *mut u8,\n length: usize,\n capacity: usize,\n) -> String

Creates a new String from a pointer, a length and a capacity.

\n
§Safety
\n

This is highly unsafe, due to the number of invariants that aren’t\nchecked:

\n\n

Violating these may cause problems like corrupting the allocator’s\ninternal data structures. For example, it is normally not safe to\nbuild a String from a pointer to a C char array containing UTF-8\nunless you are certain that array was originally allocated by the\nRust standard library’s allocator.

\n

The ownership of buf is effectively transferred to the\nString which may then deallocate, reallocate or change the\ncontents of memory pointed to by the pointer at will. Ensure\nthat nothing else uses the pointer after calling this\nfunction.

\n
§Examples
\n
use std::mem;\n\nunsafe {\n    let s = String::from(\"hello\");\n\n    // Prevent automatically dropping the String's data\n    let mut s = mem::ManuallyDrop::new(s);\n\n    let ptr = s.as_mut_ptr();\n    let len = s.len();\n    let capacity = s.capacity();\n\n    let s = String::from_raw_parts(ptr, len, capacity);\n\n    assert_eq!(String::from(\"hello\"), s);\n}
1.0.0 · Source

pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String

Converts a vector of bytes to a String without checking that the\nstring contains valid UTF-8.

\n

See the safe version, from_utf8, for more details.

\n
§Safety
\n

This function is unsafe because it does not check that the bytes passed\nto it are valid UTF-8. If this constraint is violated, it may cause\nmemory unsafety issues with future users of the String, as the rest of\nthe standard library assumes that Strings are valid UTF-8.

\n
§Examples
\n
// some bytes, in a vector\nlet sparkle_heart = vec![240, 159, 146, 150];\n\nlet sparkle_heart = unsafe {\n    String::from_utf8_unchecked(sparkle_heart)\n};\n\nassert_eq!(\"💖\", sparkle_heart);
1.0.0 (const: 1.87.0) · Source

pub const fn into_bytes(self) -> Vec<u8>

Converts a String into a byte vector.

\n

This consumes the String, so we do not need to copy its contents.

\n
§Examples
\n
let s = String::from(\"hello\");\nlet bytes = s.into_bytes();\n\nassert_eq!(&[104, 101, 108, 108, 111][..], &bytes[..]);
1.7.0 (const: 1.87.0) · Source

pub const fn as_str(&self) -> &str

Extracts a string slice containing the entire String.

\n
§Examples
\n
let s = String::from(\"foo\");\n\nassert_eq!(\"foo\", s.as_str());
1.7.0 (const: 1.87.0) · Source

pub const fn as_mut_str(&mut self) -> &mut str

Converts a String into a mutable string slice.

\n
§Examples
\n
let mut s = String::from(\"foobar\");\nlet s_mut_str = s.as_mut_str();\n\ns_mut_str.make_ascii_uppercase();\n\nassert_eq!(\"FOOBAR\", s_mut_str);
1.0.0 · Source

pub fn push_str(&mut self, string: &str)

Appends a given string slice onto the end of this String.

\n
§Examples
\n
let mut s = String::from(\"foo\");\n\ns.push_str(\"bar\");\n\nassert_eq!(\"foobar\", s);
1.87.0 · Source

pub fn extend_from_within<R>(&mut self, src: R)
where\n R: RangeBounds<usize>,

Copies elements from src range to the end of the string.

\n
§Panics
\n

Panics if the starting point or end point do not lie on a char\nboundary, or if they’re out of bounds.

\n
§Examples
\n
let mut string = String::from(\"abcde\");\n\nstring.extend_from_within(2..);\nassert_eq!(string, \"abcdecde\");\n\nstring.extend_from_within(..2);\nassert_eq!(string, \"abcdecdeab\");\n\nstring.extend_from_within(4..8);\nassert_eq!(string, \"abcdecdeabecde\");
1.0.0 (const: 1.87.0) · Source

pub const fn capacity(&self) -> usize

Returns this String’s capacity, in bytes.

\n
§Examples
\n
let s = String::with_capacity(10);\n\nassert!(s.capacity() >= 10);
1.0.0 · Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional bytes more than the\ncurrent length. The allocator may reserve more space to speculatively\navoid frequent allocations. After calling reserve,\ncapacity will be greater than or equal to self.len() + additional.\nDoes nothing if capacity is already sufficient.

\n
§Panics
\n

Panics if the new capacity overflows usize.

\n
§Examples
\n

Basic usage:

\n\n
let mut s = String::new();\n\ns.reserve(10);\n\nassert!(s.capacity() >= 10);
\n

This might not actually increase the capacity:

\n\n
let mut s = String::with_capacity(10);\ns.push('a');\ns.push('b');\n\n// s now has a length of 2 and a capacity of at least 10\nlet capacity = s.capacity();\nassert_eq!(2, s.len());\nassert!(capacity >= 10);\n\n// Since we already have at least an extra 8 capacity, calling this...\ns.reserve(8);\n\n// ... doesn't actually increase.\nassert_eq!(capacity, s.capacity());
1.0.0 · Source

pub fn reserve_exact(&mut self, additional: usize)

Reserves the minimum capacity for at least additional bytes more than\nthe current length. Unlike reserve, this will not\ndeliberately over-allocate to speculatively avoid frequent allocations.\nAfter calling reserve_exact, capacity will be greater than or equal to\nself.len() + additional. Does nothing if the capacity is already\nsufficient.

\n
§Panics
\n

Panics if the new capacity overflows usize.

\n
§Examples
\n

Basic usage:

\n\n
let mut s = String::new();\n\ns.reserve_exact(10);\n\nassert!(s.capacity() >= 10);
\n

This might not actually increase the capacity:

\n\n
let mut s = String::with_capacity(10);\ns.push('a');\ns.push('b');\n\n// s now has a length of 2 and a capacity of at least 10\nlet capacity = s.capacity();\nassert_eq!(2, s.len());\nassert!(capacity >= 10);\n\n// Since we already have at least an extra 8 capacity, calling this...\ns.reserve_exact(8);\n\n// ... doesn't actually increase.\nassert_eq!(capacity, s.capacity());
1.57.0 · Source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Tries to reserve capacity for at least additional bytes more than the\ncurrent length. The allocator may reserve more space to speculatively\navoid frequent allocations. After calling try_reserve, capacity will be\ngreater than or equal to self.len() + additional if it returns\nOk(()). Does nothing if capacity is already sufficient. This method\npreserves the contents even if an error occurs.

\n
§Errors
\n

If the capacity overflows, or the allocator reports a failure, then an error\nis returned.

\n
§Examples
\n
use std::collections::TryReserveError;\n\nfn process_data(data: &str) -> Result<String, TryReserveError> {\n    let mut output = String::new();\n\n    // Pre-reserve the memory, exiting if we can't\n    output.try_reserve(data.len())?;\n\n    // Now we know this can't OOM in the middle of our complex work\n    output.push_str(data);\n\n    Ok(output)\n}
1.57.0 · Source

pub fn try_reserve_exact(\n &mut self,\n additional: usize,\n) -> Result<(), TryReserveError>

Tries to reserve the minimum capacity for at least additional bytes\nmore than the current length. Unlike try_reserve, this will not\ndeliberately over-allocate to speculatively avoid frequent allocations.\nAfter calling try_reserve_exact, capacity will be greater than or\nequal to self.len() + additional if it returns Ok(()).\nDoes nothing if the capacity is already sufficient.

\n

Note that the allocator may give the collection more space than it\nrequests. Therefore, capacity can not be relied upon to be precisely\nminimal. Prefer try_reserve if future insertions are expected.

\n
§Errors
\n

If the capacity overflows, or the allocator reports a failure, then an error\nis returned.

\n
§Examples
\n
use std::collections::TryReserveError;\n\nfn process_data(data: &str) -> Result<String, TryReserveError> {\n    let mut output = String::new();\n\n    // Pre-reserve the memory, exiting if we can't\n    output.try_reserve_exact(data.len())?;\n\n    // Now we know this can't OOM in the middle of our complex work\n    output.push_str(data);\n\n    Ok(output)\n}
1.0.0 · Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of this String to match its length.

\n
§Examples
\n
let mut s = String::from(\"foo\");\n\ns.reserve(100);\nassert!(s.capacity() >= 100);\n\ns.shrink_to_fit();\nassert_eq!(3, s.capacity());
1.56.0 · Source

pub fn shrink_to(&mut self, min_capacity: usize)

Shrinks the capacity of this String with a lower bound.

\n

The capacity will remain at least as large as both the length\nand the supplied value.

\n

If the current capacity is less than the lower limit, this is a no-op.

\n
§Examples
\n
let mut s = String::from(\"foo\");\n\ns.reserve(100);\nassert!(s.capacity() >= 100);\n\ns.shrink_to(10);\nassert!(s.capacity() >= 10);\ns.shrink_to(0);\nassert!(s.capacity() >= 3);
1.0.0 · Source

pub fn push(&mut self, ch: char)

Appends the given char to the end of this String.

\n
§Examples
\n
let mut s = String::from(\"abc\");\n\ns.push('1');\ns.push('2');\ns.push('3');\n\nassert_eq!(\"abc123\", s);
1.0.0 (const: 1.87.0) · Source

pub const fn as_bytes(&self) -> &[u8]

Returns a byte slice of this String’s contents.

\n

The inverse of this method is from_utf8.

\n
§Examples
\n
let s = String::from(\"hello\");\n\nassert_eq!(&[104, 101, 108, 108, 111], s.as_bytes());
1.0.0 · Source

pub fn truncate(&mut self, new_len: usize)

Shortens this String to the specified length.

\n

If new_len is greater than or equal to the string’s current length, this has no\neffect.

\n

Note that this method has no effect on the allocated capacity\nof the string

\n
§Panics
\n

Panics if new_len does not lie on a char boundary.

\n
§Examples
\n
let mut s = String::from(\"hello\");\n\ns.truncate(2);\n\nassert_eq!(\"he\", s);
1.0.0 · Source

pub fn pop(&mut self) -> Option<char>

Removes the last character from the string buffer and returns it.

\n

Returns None if this String is empty.

\n
§Examples
\n
let mut s = String::from(\"abč\");\n\nassert_eq!(s.pop(), Some('č'));\nassert_eq!(s.pop(), Some('b'));\nassert_eq!(s.pop(), Some('a'));\n\nassert_eq!(s.pop(), None);
1.0.0 · Source

pub fn remove(&mut self, idx: usize) -> char

Removes a char from this String at byte position idx and returns it.

\n

Copies all bytes after the removed char to new positions.

\n

Note that calling this in a loop can result in quadratic behavior.

\n
§Panics
\n

Panics if idx is larger than or equal to the String’s length,\nor if it does not lie on a char boundary.

\n
§Examples
\n
let mut s = String::from(\"abç\");\n\nassert_eq!(s.remove(0), 'a');\nassert_eq!(s.remove(1), 'ç');\nassert_eq!(s.remove(0), 'b');
Source

pub fn remove_matches<P>(&mut self, pat: P)
where\n P: Pattern,

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

Remove all matches of pattern pat in the String.

\n
§Examples
\n
#![feature(string_remove_matches)]\nlet mut s = String::from(\"Trees are not green, the sky is not blue.\");\ns.remove_matches(\"not \");\nassert_eq!(\"Trees are green, the sky is blue.\", s);
\n

Matches will be detected and removed iteratively, so in cases where\npatterns overlap, only the first pattern will be removed:

\n\n
#![feature(string_remove_matches)]\nlet mut s = String::from(\"banana\");\ns.remove_matches(\"ana\");\nassert_eq!(\"bna\", s);
1.26.0 · Source

pub fn retain<F>(&mut self, f: F)
where\n F: FnMut(char) -> bool,

Retains only the characters specified by the predicate.

\n

In other words, remove all characters c such that f(c) returns false.\nThis method operates in place, visiting each character exactly once in the\noriginal order, and preserves the order of the retained characters.

\n
§Examples
\n
let mut s = String::from(\"f_o_ob_ar\");\n\ns.retain(|c| c != '_');\n\nassert_eq!(s, \"foobar\");
\n

Because the elements are visited exactly once in the original order,\nexternal state may be used to decide which elements to keep.

\n\n
let mut s = String::from(\"abcde\");\nlet keep = [false, true, true, false, true];\nlet mut iter = keep.iter();\ns.retain(|_| *iter.next().unwrap());\nassert_eq!(s, \"bce\");
1.0.0 · Source

pub fn insert(&mut self, idx: usize, ch: char)

Inserts a character into this String at byte position idx.

\n

Reallocates if self.capacity() is insufficient, which may involve copying all\nself.capacity() bytes. Makes space for the insertion by copying all bytes of\n&self[idx..] to new positions.

\n

Note that calling this in a loop can result in quadratic behavior.

\n
§Panics
\n

Panics if idx is larger than the String’s length, or if it does not\nlie on a char boundary.

\n
§Examples
\n
let mut s = String::with_capacity(3);\n\ns.insert(0, 'f');\ns.insert(1, 'o');\ns.insert(2, 'o');\n\nassert_eq!(\"foo\", s);
1.16.0 · Source

pub fn insert_str(&mut self, idx: usize, string: &str)

Inserts a string slice into this String at byte position idx.

\n

Reallocates if self.capacity() is insufficient, which may involve copying all\nself.capacity() bytes. Makes space for the insertion by copying all bytes of\n&self[idx..] to new positions.

\n

Note that calling this in a loop can result in quadratic behavior.

\n
§Panics
\n

Panics if idx is larger than the String’s length, or if it does not\nlie on a char boundary.

\n
§Examples
\n
let mut s = String::from(\"bar\");\n\ns.insert_str(0, \"foo\");\n\nassert_eq!(\"foobar\", s);
1.0.0 (const: 1.87.0) · Source

pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8>

Returns a mutable reference to the contents of this String.

\n
§Safety
\n

This function is unsafe because the returned &mut Vec allows writing\nbytes which are not valid UTF-8. If this constraint is violated, using\nthe original String after dropping the &mut Vec may violate memory\nsafety, as the rest of the standard library assumes that Strings are\nvalid UTF-8.

\n
§Examples
\n
let mut s = String::from(\"hello\");\n\nunsafe {\n    let vec = s.as_mut_vec();\n    assert_eq!(&[104, 101, 108, 108, 111][..], &vec[..]);\n\n    vec.reverse();\n}\nassert_eq!(s, \"olleh\");
1.0.0 (const: 1.87.0) · Source

pub const fn len(&self) -> usize

Returns the length of this String, in bytes, not chars or\ngraphemes. In other words, it might not be what a human considers the\nlength of the string.

\n
§Examples
\n
let a = String::from(\"foo\");\nassert_eq!(a.len(), 3);\n\nlet fancy_f = String::from(\"ƒoo\");\nassert_eq!(fancy_f.len(), 4);\nassert_eq!(fancy_f.chars().count(), 3);
1.0.0 (const: 1.87.0) · Source

pub const fn is_empty(&self) -> bool

Returns true if this String has a length of zero, and false otherwise.

\n
§Examples
\n
let mut v = String::new();\nassert!(v.is_empty());\n\nv.push('a');\nassert!(!v.is_empty());
1.16.0 · Source

pub fn split_off(&mut self, at: usize) -> String

Splits the string into two at the given byte index.

\n

Returns a newly allocated String. self contains bytes [0, at), and\nthe returned String contains bytes [at, len). at must be on the\nboundary of a UTF-8 code point.

\n

Note that the capacity of self does not change.

\n
§Panics
\n

Panics if at is not on a UTF-8 code point boundary, or if it is beyond the last\ncode point of the string.

\n
§Examples
\n
let mut hello = String::from(\"Hello, World!\");\nlet world = hello.split_off(7);\nassert_eq!(hello, \"Hello, \");\nassert_eq!(world, \"World!\");
1.0.0 · Source

pub fn clear(&mut self)

Truncates this String, removing all contents.

\n

While this means the String will have a length of zero, it does not\ntouch its capacity.

\n
§Examples
\n
let mut s = String::from(\"foo\");\n\ns.clear();\n\nassert!(s.is_empty());\nassert_eq!(0, s.len());\nassert_eq!(3, s.capacity());
1.6.0 · Source

pub fn drain<R>(&mut self, range: R) -> Drain<'_>
where\n R: RangeBounds<usize>,

Removes the specified range from the string in bulk, returning all\nremoved characters as an iterator.

\n

The returned iterator keeps a mutable borrow on the string to optimize\nits implementation.

\n
§Panics
\n

Panics if the starting point or end point do not lie on a char\nboundary, or if they’re out of bounds.

\n
§Leaking
\n

If the returned iterator goes out of scope without being dropped (due to\ncore::mem::forget, for example), the string may still contain a copy\nof any drained characters, or may have lost characters arbitrarily,\nincluding characters outside the range.

\n
§Examples
\n
let mut s = String::from(\"α is alpha, β is beta\");\nlet beta_offset = s.find('β').unwrap_or(s.len());\n\n// Remove the range up until the β from the string\nlet t: String = s.drain(..beta_offset).collect();\nassert_eq!(t, \"α is alpha, \");\nassert_eq!(s, \"β is beta\");\n\n// A full range clears the string, like `clear()` does\ns.drain(..);\nassert_eq!(s, \"\");
Source

pub fn into_chars(self) -> IntoChars

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

Converts a String into an iterator over the chars of the string.

\n

As a string consists of valid UTF-8, we can iterate through a string\nby char. This method returns such an iterator.

\n

It’s important to remember that char represents a Unicode Scalar\nValue, and might not match your idea of what a ‘character’ is. Iteration\nover grapheme clusters may be what you actually want. That functionality\nis not provided by Rust’s standard library, check crates.io instead.

\n
§Examples
\n

Basic usage:

\n\n
#![feature(string_into_chars)]\n\nlet word = String::from(\"goodbye\");\n\nlet mut chars = word.into_chars();\n\nassert_eq!(Some('g'), chars.next());\nassert_eq!(Some('o'), chars.next());\nassert_eq!(Some('o'), chars.next());\nassert_eq!(Some('d'), chars.next());\nassert_eq!(Some('b'), chars.next());\nassert_eq!(Some('y'), chars.next());\nassert_eq!(Some('e'), chars.next());\n\nassert_eq!(None, chars.next());
\n

Remember, chars might not match your intuition about characters:

\n\n
#![feature(string_into_chars)]\n\nlet y = String::from(\"y̆\");\n\nlet mut chars = y.into_chars();\n\nassert_eq!(Some('y'), chars.next()); // not 'y̆'\nassert_eq!(Some('\\u{0306}'), chars.next());\n\nassert_eq!(None, chars.next());
1.27.0 · Source

pub fn replace_range<R>(&mut self, range: R, replace_with: &str)
where\n R: RangeBounds<usize>,

Removes the specified range in the string,\nand replaces it with the given string.\nThe given string doesn’t need to be the same length as the range.

\n
§Panics
\n

Panics if the starting point or end point do not lie on a char\nboundary, or if they’re out of bounds.

\n
§Examples
\n
let mut s = String::from(\"α is alpha, β is beta\");\nlet beta_offset = s.find('β').unwrap_or(s.len());\n\n// Replace the range up until the β from the string\ns.replace_range(..beta_offset, \"Α is capital alpha; \");\nassert_eq!(s, \"Α is capital alpha; β is beta\");
1.4.0 · Source

pub fn into_boxed_str(self) -> Box<str>

Converts this String into a Box<str>.

\n

Before doing the conversion, this method discards excess capacity like shrink_to_fit.\nNote that this call may reallocate and copy the bytes of the string.

\n
§Examples
\n
let s = String::from(\"hello\");\n\nlet b = s.into_boxed_str();
1.72.0 · Source

pub fn leak<'a>(self) -> &'a mut str

Consumes and leaks the String, returning a mutable reference to the contents,\n&'a mut str.

\n

The caller has free choice over the returned lifetime, including 'static. Indeed,\nthis function is ideally used for data that lives for the remainder of the program’s life,\nas dropping the returned reference will cause a memory leak.

\n

It does not reallocate or shrink the String, so the leaked allocation may include unused\ncapacity that is not part of the returned slice. If you want to discard excess capacity,\ncall into_boxed_str, and then Box::leak instead. However, keep in mind that\ntrimming the capacity may result in a reallocation and copy.

\n
§Examples
\n
let x = String::from(\"bucket\");\nlet static_ref: &'static mut str = x.leak();\nassert_eq!(static_ref, \"bucket\");
",0,"jsonpath_rust::query::QueryPath"],["
1.16.0 · Source§

impl ToSocketAddrs for String

Source§

type Iter = IntoIter<SocketAddr>

Returned iterator over socket addresses which this type may correspond\nto.
Source§

fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>, Error>

Converts this object to an iterator of resolved SocketAddrs. Read more
","ToSocketAddrs","jsonpath_rust::query::QueryPath"],["
Source§

impl<'a> TryFrom<&'a ByteStr> for String

Source§

type Error = Utf8Error

The type returned in the event of a conversion error.
Source§

fn try_from(\n s: &'a ByteStr,\n) -> Result<String, <String as TryFrom<&'a ByteStr>>::Error>

Performs the conversion.
","TryFrom<&'a ByteStr>","jsonpath_rust::query::QueryPath"],["
Source§

impl TryFrom<ByteString> for String

Source§

type Error = FromUtf8Error

The type returned in the event of a conversion error.
Source§

fn try_from(\n s: ByteString,\n) -> Result<String, <String as TryFrom<ByteString>>::Error>

Performs the conversion.
","TryFrom","jsonpath_rust::query::QueryPath"],["
1.85.0 · Source§

impl TryFrom<CString> for String

Source§

fn try_from(\n value: CString,\n) -> Result<String, <String as TryFrom<CString>>::Error>

Converts a CString into a String if it contains valid UTF-8 data.

\n

This method is equivalent to CString::into_string.

\n
Source§

type Error = IntoStringError

The type returned in the event of a conversion error.
","TryFrom","jsonpath_rust::query::QueryPath"],["
1.87.0 · Source§

impl TryFrom<Vec<u8>> for String

Source§

fn try_from(\n bytes: Vec<u8>,\n) -> Result<String, <String as TryFrom<Vec<u8>>>::Error>

Converts the given Vec<u8> into a String if it contains valid UTF-8 data.

\n
§Examples
\n
let s1 = b\"hello world\".to_vec();\nlet v1 = String::try_from(s1).unwrap();\nassert_eq!(v1, \"hello world\");\n
Source§

type Error = FromUtf8Error

The type returned in the event of a conversion error.
","TryFrom>","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Write for String

Source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write\nsucceeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
","Write","jsonpath_rust::query::QueryPath"],["
Source§

impl DerefPure for String

","DerefPure","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl Eq for String

","Eq","jsonpath_rust::query::QueryPath"],["
Source§

impl Index for String

","Index","jsonpath_rust::query::QueryPath"],["
1.0.0 · Source§

impl StructuralPartialEq for String

","StructuralPartialEq","jsonpath_rust::query::QueryPath"]]]]); if (window.register_type_impls) { window.register_type_impls(type_impls); } else { window.pending_type_impls = type_impls; } })() //{"start":55,"fragment_lengths":[278732]}