#[derive(Debug)] struct MyKey(String); impl From<&'static str> for MyKey { #[inline(always)] fn from(data: &'static str) -> MyKey { MyKey(data.into()) } } impl From<String> for MyKey { fn from(data: String) -> MyKey { MyKey(data) } } fn main() { let string: String = "testing".into(); let my_key = MyKey::from(string.clone()); dbg!(my_key); }