iter/iter.rs
1use mut_str::StrExt;
2
3fn main() {
4 let mut s = Box::<str>::from("oφ⏣🌑");
5
6 // Iterate over the characters printing their length and bytes
7 s.ref_iter()
8 .for_each(|c| println!("{c:?}\tlength: {}, bytes: {:?}", c.len(), c.as_bytes()));
9
10 // Iterate over each character trying to make them uppercase
11 // (Result::ok is being used to ignore the result)
12 s.mut_iter().for_each(|c| {
13 c.try_make_uppercase().ok();
14 });
15
16 println!("\n{s:?}");
17}
18
19// Test the example (this can be ignored)
20#[test]
21fn test() {
22 main();
23}