Struct non_empty_string::NonEmptyString
source · #[repr(transparent)]pub struct NonEmptyString(_);
Expand description
A simple String wrapper type, similar to NonZeroUsize and friends. Guarantees that the String contained inside is not of length 0.
Implementations§
source§impl NonEmptyString
impl NonEmptyString
sourcepub fn new(string: String) -> Result<NonEmptyString, String>
pub fn new(string: String) -> Result<NonEmptyString, String>
Attempts to create a new NonEmptyString.
If the given string
is empty, Err
is returned, containing the original String
, Ok
otherwise.
sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consume the NonEmptyString
to get the internal String
out.
sourcepub fn into_bytes(self) -> Vec<u8>
pub fn into_bytes(self) -> Vec<u8>
Is forwarded to the inner String.
See std::string::String::into_bytes
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Is forwarded to the inner String.
See std::string::String::as_str
sourcepub fn push_str(&mut self, string: &str)
pub fn push_str(&mut self, string: &str)
Is forwarded to the inner String.
See std::string::String::push_str
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Is forwarded to the inner String.
See std::string::String::capacity
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Is forwarded to the inner String.
See std::string::String::reserve
sourcepub fn reserve_exact(&mut self, additional: usize)
pub fn reserve_exact(&mut self, additional: usize)
Is forwarded to the inner String.
See std::string::String::reserve_exact
sourcepub fn try_reserve_exact(
&mut self,
additional: usize
) -> Result<(), TryReserveError>
pub fn try_reserve_exact(
&mut self,
additional: usize
) -> Result<(), TryReserveError>
Is forwarded to the inner String.
See std::string::String::try_reserve_exact
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Is forwarded to the inner String.
See std::string::String::[(&
]
sourcepub fn shrink_to(&mut self, min_capacity: usize)
pub fn shrink_to(&mut self, min_capacity: usize)
Is forwarded to the inner String.
See std::string::String::shrink_to
sourcepub fn push(&mut self, ch: char)
pub fn push(&mut self, ch: char)
Is forwarded to the inner String.
See std::string::String::push
sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Is forwarded to the inner String.
See std::string::String::as_bytes
sourcepub fn insert(&mut self, idx: usize, ch: char)
pub fn insert(&mut self, idx: usize, ch: char)
Is forwarded to the inner String.
See std::string::String::insert
sourcepub fn insert_str(&mut self, idx: usize, string: &str)
pub fn insert_str(&mut self, idx: usize, string: &str)
Is forwarded to the inner String.
See std::string::String::insert_str
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Is forwarded to the inner String.
See std::string::String::len
sourcepub fn into_boxed_str(self) -> Box<str>
pub fn into_boxed_str(self) -> Box<str>
Is forwarded to the inner String.
See std::string::String::into_boxed_str
Trait Implementations§
source§impl AsRef<String> for NonEmptyString
impl AsRef<String> for NonEmptyString
source§impl AsRef<str> for NonEmptyString
impl AsRef<str> for NonEmptyString
source§impl Clone for NonEmptyString
impl Clone for NonEmptyString
source§fn clone(&self) -> NonEmptyString
fn clone(&self) -> NonEmptyString
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for NonEmptyString
impl Debug for NonEmptyString
source§impl Display for NonEmptyString
impl Display for NonEmptyString
source§impl Ord for NonEmptyString
impl Ord for NonEmptyString
source§fn cmp(&self, other: &NonEmptyString) -> Ordering
fn cmp(&self, other: &NonEmptyString) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<NonEmptyString> for NonEmptyString
impl PartialEq<NonEmptyString> for NonEmptyString
source§fn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
source§impl PartialOrd<NonEmptyString> for NonEmptyString
impl PartialOrd<NonEmptyString> for NonEmptyString
source§fn partial_cmp(&self, other: &NonEmptyString) -> Option<Ordering>
fn partial_cmp(&self, other: &NonEmptyString) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more