Guest User

Untitled

a guest
Sep 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. fn truncate_empty_str_suffix<'a>(list: &'a [&'a str]) -> &'a [&'a str] {
  2. let mut last_ind=0;
  3. for (i,elem) in list.iter().enumerate() {
  4. if !elem.is_empty() {
  5. last_ind=i+1;
  6. }
  7. }
  8. &list[..last_ind]
  9. }
  10.  
  11. fn main() {
  12. println!("{:?}", truncate_empty_str_suffix(&["", "bar", "", ""]));
  13. }
Add Comment
Please, Sign In to add comment