pub struct FieldName(/* private fields */);
Implementations§
Methods from Deref<Target = AsciiString>§
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of bytes that this ASCII string buffer can hold without reallocating.
§Examples
let s = String::with_capacity(10);
assert!(s.capacity() >= 10);
Methods from Deref<Target = AsciiStr>§
Sourcepub fn as_mut_slice(&mut self) -> &mut [AsciiChar]
pub fn as_mut_slice(&mut self) -> &mut [AsciiChar]
Returns the entire string as mutable slice of AsciiChar
s.
Sourcepub fn as_ptr(&self) -> *const AsciiChar
pub fn as_ptr(&self) -> *const AsciiChar
Returns a raw pointer to the AsciiStr
’s buffer.
The caller must ensure that the slice outlives the pointer this function returns, or else it
will end up pointing to garbage. Modifying the AsciiStr
may cause it’s buffer to be
reallocated, which would also make any pointers to it invalid.
Sourcepub fn as_mut_ptr(&mut self) -> *mut AsciiChar
pub fn as_mut_ptr(&mut self) -> *mut AsciiChar
Returns an unsafe mutable pointer to the AsciiStr
’s buffer.
The caller must ensure that the slice outlives the pointer this function returns, or else it
will end up pointing to garbage. Modifying the AsciiStr
may cause it’s buffer to be
reallocated, which would also make any pointers to it invalid.
Sourcepub fn to_ascii_string(&self) -> AsciiString
Available on crate feature alloc
only.
pub fn to_ascii_string(&self) -> AsciiString
alloc
only.Copies the content of this AsciiStr
into an owned AsciiString
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of characters / bytes in this ASCII sequence.
§Examples
let s = AsciiStr::from_ascii("foo").unwrap();
assert_eq!(s.len(), 3);
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the ASCII slice contains zero bytes.
§Examples
let mut empty = AsciiStr::from_ascii("").unwrap();
let mut full = AsciiStr::from_ascii("foo").unwrap();
assert!(empty.is_empty());
assert!(!full.is_empty());
Sourcepub fn chars_mut(&mut self) -> CharsMut<'_>
pub fn chars_mut(&mut self) -> CharsMut<'_>
Returns an iterator over the characters of the AsciiStr
which allows you to modify the
value of each AsciiChar
.
Sourcepub fn split(&self, on: AsciiChar) -> impl DoubleEndedIterator
pub fn split(&self, on: AsciiChar) -> impl DoubleEndedIterator
Returns an iterator over parts of the AsciiStr
separated by a character.
§Examples
let words = AsciiStr::from_ascii("apple banana lemon").unwrap()
.split(AsciiChar::Space)
.map(|a| a.as_str())
.collect::<Vec<_>>();
assert_eq!(words, ["apple", "banana", "lemon"]);
Sourcepub fn lines(&self) -> impl DoubleEndedIterator
pub fn lines(&self) -> impl DoubleEndedIterator
Returns an iterator over the lines of the AsciiStr
, which are themselves AsciiStr
s.
Lines are ended with either LineFeed
(\n
), or CarriageReturn
then LineFeed
(\r\n
).
The final line ending is optional.
Sourcepub fn trim(&self) -> &AsciiStr
pub fn trim(&self) -> &AsciiStr
Returns an ASCII string slice with leading and trailing whitespace removed.
§Examples
let example = AsciiStr::from_ascii(" \twhite \tspace \t").unwrap();
assert_eq!("white \tspace", example.trim());
Sourcepub fn trim_start(&self) -> &AsciiStr
pub fn trim_start(&self) -> &AsciiStr
Returns an ASCII string slice with leading whitespace removed.
§Examples
let example = AsciiStr::from_ascii(" \twhite \tspace \t").unwrap();
assert_eq!("white \tspace \t", example.trim_start());
Sourcepub fn trim_end(&self) -> &AsciiStr
pub fn trim_end(&self) -> &AsciiStr
Returns an ASCII string slice with trailing whitespace removed.
§Examples
let example = AsciiStr::from_ascii(" \twhite \tspace \t").unwrap();
assert_eq!(" \twhite \tspace", example.trim_end());
Sourcepub fn eq_ignore_ascii_case(&self, other: &AsciiStr) -> bool
pub fn eq_ignore_ascii_case(&self, other: &AsciiStr) -> bool
Compares two strings case-insensitively.
Sourcepub fn make_ascii_uppercase(&mut self)
pub fn make_ascii_uppercase(&mut self)
Replaces lowercase letters with their uppercase equivalent.
Sourcepub fn make_ascii_lowercase(&mut self)
pub fn make_ascii_lowercase(&mut self)
Replaces uppercase letters with their lowercase equivalent.
Sourcepub fn to_ascii_uppercase(&self) -> AsciiString
Available on crate feature alloc
only.
pub fn to_ascii_uppercase(&self) -> AsciiString
alloc
only.Returns a copy of this string where letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’.
Sourcepub fn to_ascii_lowercase(&self) -> AsciiString
Available on crate feature alloc
only.
pub fn to_ascii_lowercase(&self) -> AsciiString
alloc
only.Returns a copy of this string where letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’.