Skip to content

Commit 3a0f8b1

Browse files
committed
add strings binary (episode 13)
1 parent 301c2b1 commit 3a0f8b1

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

strings/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "strings"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]

strings/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
fn main() {
2+
let s: &'static str = "hello😅👋🏼👋🏿你好";
3+
for char in s.chars() {
4+
println!("{}", char)
5+
}
6+
println!(
7+
"{} = sizeof(char) ({} = MAX chars, unlike {} u32 MAX)",
8+
std::mem::size_of::<char>(),
9+
char::MAX as u32,
10+
u32::MAX
11+
);
12+
println!("{:?}", &s[..9]);
13+
s.to_owned().push('c');
14+
s.to_owned().push_str("c");
15+
}

0 commit comments

Comments
 (0)