Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Designs and reviews Rust trait APIs, generic bounds, trait objects, and conversion traits for public crate interfaces.
96% 100%+4 ptsof test cases passed
Passed 23 of 23 test cases with the skill, and 22 of 23 without it.
I am writing a new local helper function in a Rust module to parse data from a `std::fs::File`. This function is only called from one single location in my private module. Should I make it generic `fn parse<R: Read>(reader: R)` or keep it concrete `fn parse(file: &File)`?
Recommends keeping the concrete `File` parameter type
3 of 3 safety checks passed
Use this skill to make Rust APIs generic where useful, concrete where simpler, and object-safe when dynamic dispatch is part of the design. Optimize for the smallest capability contract that callers and implementors can understand.
dyn Trait for heterogeneous values, plugin-like extension points, or runtime
dispatch.where clauses when
bounds are long or involve associated types.From, TryFrom, AsRef, AsMut,
Borrow, ToOwned, and Cow.impl Trait or a named generic for parameters when callers should
pass many concrete types.impl Trait when hiding one concrete return type. Return Box<dyn Trait> when the concrete type varies at runtime.From for infallible conversions and TryFrom for fallible
conversions. Implementing these gives callers Into and TryInto.AsRef for cheap reference-to-reference conversion. Use Borrow only
when borrowed and owned forms have equivalent Eq, Hash, and Ord
behavior.Next to this one in the catalogue, plus more from the same author.