mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-04-30 18:28:15 +08:00
16 lines
251 B
Rust
16 lines
251 B
Rust
|
// 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() {}
|