Ad
  • Custom User Avatar

    Because lst is a slice of u8s and slices are non-owning by definition, calling lst.iter() results in an iterator of references to u8s (Iterator<Item = &u8>).

    The return type of the delete_nth function is Vec<u8>, which can be built through .collect() only from an iterator over owned values (Iterator<Item = u8>).

    The iterator methods which allow such a conversion (from Iterator<Item = &u8> to Iterator<Item = u8>) are .cloned() and .copied() (either one works in this case).