mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
277 B
16 lines
277 B
3 years ago
|
// ANCHOR: all
|
||
|
fn main() {
|
||
|
// ANCHOR: here
|
||
|
let s1 = String::from("hello");
|
||
|
|
||
|
let len = calculate_length(&s1);
|
||
|
// ANCHOR_END: here
|
||
|
|
||
|
println!("The length of '{}' is {}.", s1, len);
|
||
|
}
|
||
|
|
||
|
fn calculate_length(s: &String) -> usize {
|
||
|
s.len()
|
||
|
}
|
||
|
// ANCHOR_END: all
|