3 ms·
So... Don't give the trait methods that don't apply to every member of the trait. Only implement write methods on the concrete Write implementation.
by dwattttt 1y ago
So... Don't give the trait methods that don't apply to every member of the trait. Only implement write methods on the concrete Write implementation.
- nesarkvechnep 1y agoSo… you lose the ability to have a generic parameter which implements the trait. You need to know the concrete implementation in order to know if there’s a write method, for example.
- dwattttt 1y agoIt doesn't sound like they're making multiple implementations that can write? If they were, they could make a trait for a Writable fs. But from their description it sounded like exactly two concrete implementations, one read-only, one read-write. If you want to share code or implementations, there's lots of ways still. For example, if the read-write filesystem implementation is a superset of the read-only, put a read-only struct inside the read-write.