1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
pub struct StrReplace {
    data: String,
}

impl StrReplace {
    pub fn new(str: &str) -> StrReplace { StrReplace { data: str.to_string() } }
    pub fn replace(&mut self, search: &str, replacement: &str) -> &mut Self {
        self.data = self.data.replace(search, replacement);
        self
    }
    pub fn to_str(&self) -> &str {&self.data}
    pub fn delete(&mut self) -> &mut Self {
        self.data = "".to_string();
        self
    }
}