(s: String, k: i32)
| 12 | // 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 |
| 13 | |
| 14 | pub fn truncate_sentence(s: String, k: i32) -> String { |
| 15 | let words: Vec<String> = s.split(" ").map(|word| word.to_string()).collect(); |
| 16 | words[0..k as usize].join(" ") |
| 17 | } |
| 18 | |
| 19 | fn main() { |
| 20 | println!("{:?}", truncate_sentence("Hello how are you Contestant".to_string(), 4)); |
nothing calls this directly
no outgoing calls
no test coverage detected