You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend::extend takes an IntoIterator. Since every Iterator is also an IntoIterator, you can extend from an iterator; collect() an iterator before extend() from it leads to extra memory allocations and extra copying, and is probably a mistake.
Lint Name
extend_collect
Category
suspicious, perf
Advantage
Fewer memory allocations and fewer copying.
Drawbacks
Maybe collect() actually leads to a performance boost because of, say, better cache behavior, and is actually intentional.
Example
letmut v = vec![0i32];
v.extend((1..10).collect::<Vec<_>>());