use crate::{Counter, String, Vec};
use alloc::borrow::Cow;
use alloc::boxed::Box;
impl<C: Counter<usize>> From<Box<str>> for String<C> {
#[inline]
fn from(s: Box<str>) -> Self {
Self::from_boxed_str(s)
}
}
impl<C: Counter<usize>> From<&str> for String<C> {
#[inline]
fn from(s: &str) -> Self {
Self::from_boxed_str(s.into())
}
}
impl<C: Counter<usize>> From<&mut str> for String<C> {
#[inline]
fn from(s: &mut str) -> Self {
Self::from_boxed_str(s.into())
}
}
impl<C1: Counter<usize>, C2: Counter<usize>> From<&String<C2>> for String<C1> {
#[inline]
fn from(s: &String<C2>) -> Self {
Self::from_boxed_str(s.as_str().into())
}
}
impl<C: Counter<usize>> From<&alloc::string::String> for String<C> {
#[inline]
fn from(s: &alloc::string::String) -> Self {
Self::from(s.as_str())
}
}
impl<C: Counter<usize>> From<alloc::string::String> for String<C> {
#[inline]
fn from(s: alloc::string::String) -> Self {
Self::from_boxed_str(s.into_boxed_str())
}
}
impl<C: Counter<usize>> From<&String<C>> for alloc::string::String {
#[inline]
fn from(s: &String<C>) -> Self {
alloc::string::String::from(s.as_str())
}
}
impl<C: Counter<usize>> From<String<C>> for alloc::string::String {
#[inline]
fn from(s: String<C>) -> Self {
alloc::string::String::from(s.as_str())
}
}
impl<C: Counter<usize>> From<Cow<'_, str>> for String<C> {
#[inline]
fn from(s: Cow<'_, str>) -> Self {
match s {
Cow::Borrowed(s) => Self::from_boxed_str(s.into()),
Cow::Owned(s) => Self::from_boxed_str(s.into_boxed_str()),
}
}
}
impl<C: Counter<usize>, T> From<Box<[T]>> for Vec<C, T> {
#[inline]
fn from(data: Box<[T]>) -> Self {
Self::from_boxed_slice(data)
}
}