Warning
This post was published 62 days ago. The information described in this article may have changed.
Hi folks,
I wonder if I pass Vec<String>
into the following functions:
fn non_generic_fn(s: Vec<String>) -> Vec<String> {
s
}
fn generic_fn<V, T>(s: V) -> Vec<String>
where
V: IntoIterator<Item = String>,
{
s.into_iter().collect()
}
fn even_more_generic_fn<V, T>(s: V) -> Vec<String>
where
V: IntoIterator<Item = T>,
T: Into<String>,
{
s.into_iter().map(|s| s.into()).collect()
}
will I get any performance penalties for the generic versions? Or is the compiler clever enough to understand that I'm already passing Vec
and therefore nothing to do?
Thank you.
4 posts - 3 participants
🏷️ rust_feed