Function mut_str::copy_to

source ·
pub fn copy_to<'a>(s: &str, buffer: &'a mut [u8]) -> Option<&'a mut str>
Expand description

Copy the str to a byte buffer and get the new str containing the inserted character. Returns None if buffer is shorter than the string slice.

use mut_str::copy_to;

let s = "Hello, World!";
let mut buffer = [0; 50];
let new_s = copy_to(s, &mut buffer).unwrap();

assert_eq!(new_s, s);