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.
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
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl 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
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
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>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<NonEmptyString> for NonEmptyString
impl PartialEq<NonEmptyString> for NonEmptyString
sourcefn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'s> TryFrom<&'s str> for NonEmptyString
impl<'s> TryFrom<&'s str> for NonEmptyString
impl Eq for NonEmptyString
impl StructuralEq for NonEmptyString
impl StructuralPartialEq for NonEmptyString
Auto Trait Implementations
impl RefUnwindSafe for NonEmptyString
impl Send for NonEmptyString
impl Sync for NonEmptyString
impl Unpin for NonEmptyString
impl UnwindSafe for NonEmptyString
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more