Created
March 1, 2023 10:57
-
-
Save juliarose/72a141b93827fba02d24808697b71039 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut s = String::with_capacity(100); | |
s.push_str("coffee and 🍌"); | |
s.shrink_to_fit(); | |
println!("`{s}` {} {}", s.len(), s.capacity()); | |
for c in '0'..='🍌' { | |
if c.is_control() { | |
// exclude controls, they mess up the output | |
continue; | |
} | |
let mut buf = vec![0; c.len_utf8()]; | |
c.encode_utf8(&mut buf); | |
println!("{c} {buf:?}", ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment