Rust .trim()

[Solved] Rust .trim() | Rust - Code Explorer | yomemimo.com
Question : rust .trim()

Answered by : himanshu-jangid

fn main() { // create some strings let string1 = " Welcome to Edpresso "; let string2 = "Educative is the best! "; let string3 = " Rust is very interesting!"; // trim the strings let trim1 = string1.trim(); let trim2 = string2.trim(); let trim3 = string3.trim(); // print the trims println!("The string before trim is '{}' and length is {}", string1, string1.len()); println!("The string when trimmed is '{}' and length is {}", trim1, trim1.len()); println!("\nThe string before trim is '{}' and length is {}", string2, string2.len()); println!("The string when trimmed is '{}' and length is {}", trim2, trim2.len()); println!("\nThe string before trim is '{}' and length is {}", string3, string3.len()); println!("The string when trimmed is '{}' and length is {}", trim3, trim3.len());
}

Source : https://www.educative.io/answers/what-is-the-stringtrim-method-in-rust | Last Update : Sun, 31 Jul 22

Answers related to rust .trim()

Code Explorer Popular Question For Rust