copy_from_str
Extension methods for copying strings into a string.
This crate provides copy_from_str
function which can be used to
mutate Rust strings. It works similarly to [copy_from_slice
] from
standard library except it is for strings.
```rust use copyfromstr::CopyFromStrExt;
fn makeasciiuppercase(mut input: &mut str) { let mut buffer = [0; 4]; while let Some(ch) = input.chars().next() { let src = ch.toasciiuppercase().encodeutf8(&mut buffer); let (touppercase, rest) = { input }.splitatmut(ch.lenutf8()); touppercase.copyfromstr(src); input = rest; } }
let mut str = String::from("Hello, world! 💯"); makeasciiuppercase(&mut str); assert_eq!(str, "HELLO, WORLD! 💯"); ```