doc.rust-lang.org
pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String
Converts a vector of bytes to a String without checking that the string contains valid UTF-8.
associated_function
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn insert(&mut self, idx: usize, ch: char)
Inserts a character into this String at byte position idx.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn insert_str(&mut self, idx: usize, string: &str)
Inserts a string slice into this String at byte position idx.
method
alloc
Stable since 1.16.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_boxed_str(self) -> Box<str>
Converts this String into a Box<strstr>.
method
alloc
Stable since 1.4.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn into_bytes(self) -> Vec<u8>
Converts a String into a byte vector.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_raw_parts(self) -> (*mut u8, usize, usize)
Decomposes a String into its raw components: (pointer, length, capacity).
method
alloc
Stable since 1.93.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn is_empty(&self) -> bool
Returns true if this String has a length of zero, and false otherwise.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn leak<'a>(self) -> &'a mut str
Consumes and leaks the String, returning a mutable reference to the contents, &'a mut str.
method
alloc
Stable since 1.72.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn len(&self) -> usize
Returns the length of this String, in bytes, not chars or graphemes. In other words, it might not be what a human considers the length of the string.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new() -> String
Creates a new empty String.
associated_function
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn pop(&mut self) -> Option<char>
Removes the last character from the string buffer and returns it.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn push(&mut self, ch: char)
Appends the given char to the end of this String.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn push_str(&mut self, string: &str)
Appends a given string slice onto the end of this String.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn remove(&mut self, idx: usize) -> char
Removes a char from this String at byte position idx and returns it.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn replace_range<R>(&mut self, range: R, replace_with: &str)
Removes the specified range in the string, and replaces it with the given string. The given string doesn't need to be the same length as the range.
method
alloc
Stable since 1.27.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional bytes more than the current length. The allocator may reserve more space to speculatively avoid frequent allocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for at least additional bytes more than the current length. Unlike reserve, this will not deliberately over-allocate to speculatively avoid frequent allocations. After calling reserve_exact, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn retain<F>(&mut self, f: F)
Retains only the characters specified by the predicate.
method
alloc
Stable since 1.26.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of this String with a lower bound.
method
alloc
Stable since 1.56.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of this String to match its length.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly