Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn truncate_empty_str_suffix<'a>(list: &'a [&'a str]) -> &'a [&'a str] {
- let mut last_ind=0;
- for (i,elem) in list.iter().enumerate() {
- if !elem.is_empty() {
- last_ind=i+1;
- }
- }
- &list[..last_ind]
- }
- fn main() {
- println!("{:?}", truncate_empty_str_suffix(&["", "bar", "", ""]));
- }
Add Comment
Please, Sign In to add comment