-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
Hi,
I've been thinking about whether it would make sense to remove the generic Storage<T> field on the Feed struct and instead have a Box<dyn DynStorage> object on the Feed. DynStorage would be a trait with all public methods of Storage<T>. Thus, Feed<T> would just be Feed.
Benefits:
- More ergonomic to work with in code that uses Feed. This becomes more apparent on the branch that removes failure (From Failure into std::error::Error #102) where the generic type argument becomes really long and has to be carried through all code that uses
Feed. - Allows to combine both in-memory and disk-backed Feeds in a container. Currently, that wouldn't be possible.
Drawbacks:
- Cost of dynamic dispatch
I would guess that compiler optimizations might oftenly reduce the cost of dynamic dispatch if you'd only use one implementation in your code paths, but I'm not sure about it.
Opinions?
Metadata
Metadata
Assignees
Labels
No labels