mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-04-30 02:08:02 +08:00
16 lines
251 B
Rust
Executable File
16 lines
251 B
Rust
Executable File
// ANCHOR: here
|
|
fn first_word(s: &String) -> &str {
|
|
let bytes = s.as_bytes();
|
|
|
|
for (i, &item) in bytes.iter().enumerate() {
|
|
if item == b' ' {
|
|
return &s[0..i];
|
|
}
|
|
}
|
|
|
|
&s[..]
|
|
}
|
|
// ANCHOR_END: here
|
|
|
|
fn main() {}
|