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
Scan for all uses of a function, and check if the &dyn T can be replaced by &impl T.
Advantage
Avoid the overhead introduced by dynamic dispatch
Drawbacks
Code bloat and compile overhead.
Example
// A private trait that takes a dyn reference.traitTrait{fnf(writer:&mutdyn std::io::Write);}// Using that trait with concrete types.fnuse_trait(obj:implTrait){
obj.f(&mutVec::new());}
The downside is that this can introduce a lot of monomorphization bloat if the function is called with lots of different types which can result in increased compile times and bigger code size, so I'm unsure if this should be a lint. Sounds like a tradeoff decision the user should make on a case by case basis
Indeed. But then again, I think a lot of the "redundant"/"needless"/"useless"/"unnecessary" lints belong to this area of requiring a manual tradeoff. This particular lint is very helpful in my case where latency performance is crucial.
I'm not sure the complexity of this lint though. I'm not looking to add a default-allow lint that is also difficult to implement and maintain.
What it does
Scan for all uses of a function, and check if the
&dyn T
can be replaced by&impl T
.Advantage
Drawbacks
Code bloat and compile overhead.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: