#Rust vectors intersection

5 messages · Page 1 of 1 (latest)

bold sentinel
#

Try using B.iter().any(|b| b.id == a.id) as the condition to alleviate the clone, assuming that's your question

#

It's kind of annoying to do this faster, but it can be done

unreal crystal
#

yep i don't know about the any, it seems to be what I want, but it don't work in my case for any reason ... no error just 0 results

unreal crystal
#

Ok it works, I just omit that my a vec is an iterator already and doing :

B.any(...)

don't work as excepted, so my solution is to collect before...

bold sentinel
#

Oh, if it's already an iterator you'll have to clone it, which I guess doesn't affect change your original solution 😅 I'm not sure what you want to change in your solution then, cloning an iterator is basically free