Answers for "string and str to string rust"

0

string and str to string rust

pub trait Literal {
    fn literal(&self) -> String;
}

// Using the .literal() method on a String or &str returns the String.

impl Literal for String { fn literal(&self) -> String { return self.clone() } }
impl Literal for &str { fn literal(&self) -> String { return String::from(*self); } }
Posted by: Guest on February-19-2022

Browse Popular Code Answers by Language