8 lines
159 B
Rust
8 lines
159 B
Rust
|
pub fn length_of_last_word(string: String) -> i32 {
|
||
|
string
|
||
|
.split_whitespace()
|
||
|
.last()
|
||
|
.map(|word| word.len())
|
||
|
.unwrap_or_default() as i32
|
||
|
}
|