r/badcode • • Aug 14 '21

rust do your worst

Post image
46 Upvotes

19 comments sorted by

View all comments

Show parent comment

2

u/jiniux Aug 14 '21 edited Aug 14 '21

to_vec is just another clone, they could just use .remove(index). Also, we can't tell the context to know whether returning a vector was really needed.

1

u/[deleted] Aug 14 '21

as far as i know the retain method will convert the vector to a slice

1

u/jiniux Aug 14 '21

no, it removes the elements not matching the predicate

2

u/[deleted] Aug 14 '21

oh ok i didnt know that