Struct non_empty_string::NonEmptyString
source · pub struct NonEmptyString(/* private fields */);
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 String::into_bytes
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Is forwarded to the inner String.
See 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 String::push_str
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Is forwarded to the inner String.
See String::capacity
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Is forwarded to the inner String.
See 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 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 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 String::shrink_to
sourcepub fn push(&mut self, ch: char)
pub fn push(&mut self, ch: char)
Is forwarded to the inner String.
See String::push
sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Is forwarded to the inner String.
See 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 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 String::insert_str
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Is forwarded to the inner String.
See 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 String::into_boxed_str
Trait Implementations§
source§impl Add<&str> for NonEmptyString
impl Add<&str> for NonEmptyString
§type Output = NonEmptyString
type Output = NonEmptyString
+
operator.source§impl AddAssign<&str> for NonEmptyString
impl AddAssign<&str> for NonEmptyString
source§fn add_assign(&mut self, other: &str)
fn add_assign(&mut self, other: &str)
+=
operation. Read moresource§impl AsRef<String> for NonEmptyString
impl AsRef<String> for NonEmptyString
source§impl AsRef<str> for NonEmptyString
impl AsRef<str> for NonEmptyString
source§impl Borrow<String> for NonEmptyString
impl Borrow<String> for NonEmptyString
source§impl Borrow<str> for NonEmptyString
impl Borrow<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<'de> Deserialize<'de> for NonEmptyString
impl<'de> Deserialize<'de> for NonEmptyString
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
source§impl Display for NonEmptyString
impl Display for NonEmptyString
source§impl<'a> Extend<&'a char> for NonEmptyString
impl<'a> Extend<&'a char> for NonEmptyString
source§fn extend<I: IntoIterator<Item = &'a char>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = &'a char>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
#72631)source§impl<'a> Extend<&'a str> for NonEmptyString
impl<'a> Extend<&'a str> for NonEmptyString
source§fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
#72631)source§impl Extend<Box<str>> for NonEmptyString
impl Extend<Box<str>> for NonEmptyString
source§impl<'a> Extend<Cow<'a, str>> for NonEmptyString
impl<'a> Extend<Cow<'a, str>> for NonEmptyString
source§impl Extend<String> for NonEmptyString
impl Extend<String> for NonEmptyString
source§fn extend<I: IntoIterator<Item = String>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = String>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
#72631)source§impl Extend<char> for NonEmptyString
impl Extend<char> for NonEmptyString
source§fn extend<I: IntoIterator<Item = char>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = char>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
#72631)source§impl From<NonEmptyString> for String
impl From<NonEmptyString> for String
source§fn from(value: NonEmptyString) -> Self
fn from(value: NonEmptyString) -> Self
source§impl From<char> for NonEmptyString
impl From<char> for NonEmptyString
source§impl FromStr for NonEmptyString
impl FromStr for NonEmptyString
source§impl Hash for NonEmptyString
impl Hash for NonEmptyString
source§impl Index<RangeFull> for NonEmptyString
impl Index<RangeFull> for NonEmptyString
source§impl Index<RangeInclusive<usize>> for NonEmptyString
impl Index<RangeInclusive<usize>> for NonEmptyString
source§impl Index<RangeToInclusive<usize>> for NonEmptyString
impl Index<RangeToInclusive<usize>> 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<'a, 'b> PartialEq<&'a str> for NonEmptyString
impl<'a, 'b> PartialEq<&'a str> for NonEmptyString
source§impl<'a, 'b> PartialEq<Cow<'a, str>> for NonEmptyString
impl<'a, 'b> PartialEq<Cow<'a, str>> for NonEmptyString
source§impl<'a, 'b> PartialEq<NonEmptyString> for &'a str
impl<'a, 'b> PartialEq<NonEmptyString> for &'a str
source§fn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<NonEmptyString> for Cow<'a, str>
impl<'a, 'b> PartialEq<NonEmptyString> for Cow<'a, str>
source§fn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<NonEmptyString> for String
impl<'a, 'b> PartialEq<NonEmptyString> for String
source§fn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<NonEmptyString> for str
impl<'a, 'b> PartialEq<NonEmptyString> for str
source§fn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<String> for NonEmptyString
impl<'a, 'b> PartialEq<String> for NonEmptyString
source§impl<'a, 'b> PartialEq<str> for NonEmptyString
impl<'a, 'b> PartialEq<str> for NonEmptyString
source§impl PartialEq for NonEmptyString
impl PartialEq for NonEmptyString
source§fn eq(&self, other: &NonEmptyString) -> bool
fn eq(&self, other: &NonEmptyString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for NonEmptyString
impl PartialOrd 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