mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-04-22 13:38:04 +08:00
16 lines
273 B
Rust
16 lines
273 B
Rust
// ANCHOR: all
|
|
fn main() {
|
|
// ANCHOR: here
|
|
let s1 = String::from("hello");
|
|
|
|
let len = calculate_length(&s1);
|
|
// ANCHOR_END: here
|
|
|
|
println!("The length of '{s1}' is {len}.");
|
|
}
|
|
|
|
fn calculate_length(s: &String) -> usize {
|
|
s.len()
|
|
}
|
|
// ANCHOR_END: all
|