pub trait MyFrom<T> {
fn myfrom(s: T) -> Self;
}
use std::borrow::Cow;
use kstring::KString;
impl MyFrom<&str> for KString {
fn myfrom(s: &str) -> Self {
KString::from_ref(s)
}
}
impl MyFrom<&&str> for KString {
fn myfrom(s: &&str) -> Self {
KString::from_ref(*s)
}
}
impl MyFrom<&String> for KString {
fn myfrom(s: &String) -> Self {
KString::from_ref(s)
}
}
impl MyFrom<String> for KString {
fn myfrom(s: String) -> Self {
KString::from_string(s)
}
}
impl MyFrom<&KString> for KString {
fn myfrom(s: &KString) -> Self {
s.clone()
}
}
impl MyFrom<KString> for KString {
fn myfrom(s: KString) -> Self {
s
}
}
impl<'t> MyFrom<Cow<'t, str>> for KString {
fn myfrom(s: Cow<'t, str>) -> Self {
KString::from_ref(s.as_ref())
}
}
impl MyFrom<usize> for KString {
fn myfrom(val: usize) -> Self {
KString::from_string(val.to_string())
}
}
impl<'s> MyFrom<&'s str> for &'s str {
fn myfrom(s: &'s str) -> Self {
s
}
}
impl<'s> MyFrom<&&'s str> for &'s str {
fn myfrom(s: &&'s str) -> Self {
*s
}
}
impl<'s> MyFrom<&'s String> for &'s str {
fn myfrom(s: &'s String) -> Self {
s
}
}
impl<'s> MyFrom<&'s KString> for &'s str {
fn myfrom(s: &'s KString) -> Self {
s
}
}