MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / main

Function main

04_strings_unicode/rust/utf8.rs:1–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1fn main() {
2 let ascii = String::from("Hello");
3 println!(
4 "'{}': length: {} chars: {} memsize: {}",
5 ascii,
6 ascii.len(),
7 ascii.chars().count(),
8 std::mem::size_of::<String>() + ascii.len()
9 );
10 println!("{:?}", ascii.as_bytes());
11 println!("after e: {:?}", &ascii[2..]);
12
13 println!("---");
14
15 let uni = String::from("Héllö");
16 println!(
17 "'{}': length: {} chars: {} memsize: {}",
18 uni,
19 uni.len(),
20 uni.chars().count(),
21 std::mem::size_of::<String>() + uni.len()
22 );
23 println!("{:?}", uni.as_bytes());
24 println!("after é: {:?}", &uni[2..]);
25}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected