doc.rust-lang.org
pub mod sync
Thread-safe reference-counting pointers.
module
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
fn to_string(&self) -> String
Converts the given value to a String.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub trait ToString
A trait for converting a value to a String.
trait
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn with_capacity(capacity: usize) -> String
Creates a new empty String with at least the specified capacity.
associated_function
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve the minimum capacity for at least additional bytes more than the current length. Unlike try_reserve, this will not deliberately over-allocate to speculatively avoid frequent allocations. After calling try_reserve_exact, capacity will be greater than or equal to self.len() + additional if it returns Ok(()). Does nothing if the capacity is already sufficient.
method
alloc
Stable since 1.57.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional bytes more than the current length. The allocator may reserve more space to speculatively avoid frequent allocations. After calling try_reserve, capacity will be greater than or equal to self.len() + additional if it returns Ok(()). Does nothing if capacity is already sufficient. This method preserves the contents even if an error occurs.
method
alloc
Stable since 1.57.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn truncate(&mut self, new_len: usize)
Shortens this String to the specified length.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn split_off(&mut self, at: usize) -> String
Splits the string into two at the given byte index.
method
alloc
Stable since 1.16.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
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 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 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 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 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 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 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 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 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 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 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