- trim
- trim_end
- trim_start
Remove leading and trailing whitespace
- Read more about trim and the related functions.
examples/strings/trim/src/main.rs
fn main() { let text = String::from(" Some text "); println!("original: '{}'", text); println!("trim_end: '{}'", text.trim_end()); println!("trim_start: '{}'", text.trim_start()); println!("trim: '{}'", text.trim()); }
original: ' Some text ' trim_end: ' Some text' trim_start: 'Some text ' trim: 'Some text'