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
sourceimpl 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]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [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
sourceimpl AsRef<String> for NonEmptyString
impl AsRef<String> for NonEmptyString
sourceimpl AsRef<str> for NonEmptyString
impl AsRef<str> for NonEmptyString
sourceimpl Clone for NonEmptyString
impl Clone for NonEmptyString
sourcefn clone(&self) -> NonEmptyString
fn clone(&self) -> NonEmptyString
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for NonEmptyString
impl Debug for NonEmptyString
sourceimpl Ord for NonEmptyString
impl Ord for NonEmptyString
sourcefn cmp(&self, other: &NonEmptyString) -> Ordering
fn cmp(&self, other: &NonEmptyString) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialEq<NonEmptyString> for NonEmptyString
impl PartialEq<NonEmptyString> for NonEmptyString
sourcefn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
sourceimpl PartialOrd<NonEmptyString> for NonEmptyString
impl PartialOrd<NonEmptyString> for NonEmptyString
sourcefn partial_cmp(&self, other: &NonEmptyString) -> Option<Ordering>
fn partial_cmp(&self, other: &NonEmptyString) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more