Extracts a string slice containing the entire String
.
Basic usage:
let s = String::from("foo");
assert_eq!("foo", s.as_str());
Returns this String
’s capacity, in bytes.
Basic usage:
let s = String::with_capacity(10);
assert!(s.capacity() >= 10);
Returns a byte slice of this String
’s contents.
The inverse of this method is from_utf8
.
Basic usage:
let s = String::from("hello");
assert_eq!(&[104, 101, 108, 108, 111], s.as_bytes());
Returns the length of this String
, in bytes, not char
s or
graphemes. In other words, it might not be what a human considers the
length of the string.
Basic usage:
let a = String::from("foo");
assert_eq!(a.len(), 3);
let fancy_f = String::from("ƒoo");
assert_eq!(fancy_f.len(), 4);
assert_eq!(fancy_f.chars().count(), 3);
Returns true
if this String
has a length of zero, and false
otherwise.
Basic usage:
let mut v = String::new();
assert!(v.is_empty());
v.push('a');
assert!(!v.is_empty());
Immutably borrows from an owned value. Read more
Immutably borrows from an owned value. Read more
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Formats the value using the given formatter. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String
. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.