I'm trying to wrap an external generic API, which has a FromRepresentation trait implemented for most primitive types[1]. I'd like to add a way for this wrapper to collect items from this API into a collection.
My first idea was "well, every collection is FromIterator<Item>, so can't I simply use that?" But apparently, I can't, because Rust (rightfully) cannot infer the Item I want: there might be multiple impl FromRepresentation for IteratorItem which would all correspond to impl FromIterator<IteratorItem> for Container<ContainerItem>. Could this be done somehow, or would it be better if I restrict myself to a closed list of types (e.g. only Vec and HashSet)?
Specifically, this is
rusqlite::FromSql, in case this looks like an XY problem. ↩︎