Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

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); } }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #string #str #string #rust
ADD COMMENT
Topic
Name
7+6 =