doc.rust-lang.org
pub fn clear(&mut self)
Truncates this String, removing all contents.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn capacity(&self) -> usize
Returns this String's capacity, in bytes.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_str(&self) -> &str
Extracts a string slice containing the entire String.
method
alloc
Stable since 1.7.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8>
Returns a mutable reference to the contents of this String.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_mut_str(&mut self) -> &mut str
Converts a String into a mutable string slice.
method
alloc
Stable since 1.7.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_bytes(&self) -> &[u8]
Returns a byte slice of this String's contents.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct String
A UTF-8–encoded, growable string.
struct
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub type ParseError = core::convert::Infallible
A type alias for convert::InfallibleInfallible.
type_alias
alloc
Stable since 1.5.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn utf8_error(&self) -> Utf8Error
Fetch a Utf8Error to get more details about the conversion failure.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_utf8_lossy(self) -> String
Converts the bytes into a String lossily, substituting invalid UTF-8 sequences with replacement characters.
method
alloc
Stable since 1.100.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_bytes(self) -> Vec<u8>
Returns the bytes that were attempted to convert to a String.
method
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn as_bytes(&self) -> &[u8]
Returns a slice of u8s bytes that were attempted to convert to a String.
method
alloc
Stable since 1.26.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct FromUtf8Error
A possible error value when converting a String from a UTF-8 byte vector.
struct
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct FromUtf16Error
A possible error value when converting a String from a UTF-16 byte slice.
struct
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn as_str(&self) -> &str
Returns the remaining (sub)string of this iterator as a slice.
method
alloc
Stable since 1.55.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct Drain<'a>
A draining iterator for String.
struct
alloc
Stable since 1.6.0
Version 1.100.0-nightly
doc.rust-lang.org
pub mod string
A UTF-8–encoded, growable string.
module
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub unsafe fn from_boxed_utf8_unchecked(v: crate::boxed::Box<[u8]>) -> crate::boxed::Box<str>
Converts a boxed slice of bytes to a boxed string slice without checking that the string contains valid UTF-8.
function
alloc
Stable since 1.20.0
Version 1.100.0-nightly
doc.rust-lang.org
pub mod str
Utilities for the str primitive type.
module
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub mod slice
Utilities for the slice primitive type.
module
alloc
Stable since 1.0.0
Version 1.100.0-nightly