Conversions between CappedString and Box<str>
This commit is contained in:
1 parent
ab9c62d993
commit
d4c064c92e
1 file changed
+18
@@ -199,6 +199,16 @@ impl<const N: usize> TryFrom<String> for CappedString<N> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<const N: usize> TryFrom<Box<str>> for CappedString<N> {
|
||||
type Error = Error;
|
||||
|
||||
#[inline]
|
||||
fn try_from(s: Box<str>) -> Result<Self, Self::Error> {
|
||||
Self::new(&s)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<'a, const N: usize> TryFrom<Cow<'a, str>> for CappedString<N> {
|
||||
type Error = Error;
|
||||
@@ -217,6 +227,14 @@ impl<const N: usize> From<CappedString<N>> for String {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<const N: usize> From<CappedString<N>> for Box<str> {
|
||||
#[inline]
|
||||
fn from(s: CappedString<N>) -> Self {
|
||||
s.into_boxed_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl<const N: usize, const M: usize> PartialEq<CappedString<M>> for CappedString<N> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &CappedString<M>) -> bool {
|
||||
|
||||
Reference in new issue
Block a user