Because of itertools producing a
Vec<&T> when performing
partition_map, I need a way of converting the result to
&Vec<T> and thought
as_ref would be fit for the job, but no sadly not working for me:
AsRef<Vec<Box<Ob>>> is not implemented for
This answer I might be misreading that maybe this sort of conversion isn't supported by as_ref? If not, what's the simplest way to go about it?
&Vec<T>, you must somewhere have
Vec<T> itself - reference can't point to nowhere. What's the
map_partition you're referring to? I'm not able to find it in the docs.
Ah, from SO:
Note that this will clone every
T in the vector - this might be expensive and/or undesirable, depending on your task and the
T in question.
yes, you're right I don't like the solution I found either for that reason.
Here is the "partitions_map" (sorry, dyslexia) I'm using:
Could you share the code yielding
Vec<&V>? Looking at the docs, it seems that
partition_map will output containers holding the same type you've returned from the passed closure, so either this closure or the incoming iterator might be giving you something you're not expecting.
Good call - I've updated link in my question to include my use of itertools
Couldn't you just replace
ob.into_iter()? This should yield the owned values for the whole pipeline.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.