chars
RS-W1095Extending one String with another is possible through .extend(s.chars())
.
However, this is better expressed using push_str(s)
.
let mut greeting = String::from("Hello");
greeting.extend(", ".chars());
let name = String::from("Ferris");
greeting.extend(name.chars());
assert_eq!(greeting, "Hello, Ferris");
let mut greeting = String::from("Hello");
greeting.push_str(", ");
let name = String::from("Ferris");
greeting.push_str(&name);
assert_eq!(greeting, "Hello, Ferris");