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
Informs the user about a more concise way to create a vector with a known capacity.
I often wrote code like the following:
{letmut v = vec![];
v.reserve(space_hint);
v
}
since I didn't know about the existence of Vec::with_capacity, maybe clippy can warn about things like that? It also seems like this can be generalized to cases when we are pushing into an empty vector for a known amount of times.
Advantage
No response
Drawbacks
No response
Example
{letmut v = vec![];
v.reserve(space_hint);
v
}
Could be written as:
Vec::with_capacity(space_hint)
The text was updated successfully, but these errors were encountered:
What it does
Informs the user about a more concise way to create a vector with a known capacity.
I often wrote code like the following:
since I didn't know about the existence of
Vec::with_capacity
, maybe clippy can warn about things like that? It also seems like this can be generalized to cases when we are pushing into an empty vector for a known amount of times.Advantage
No response
Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: