4 ms·
If the filesystem is a trait which has a read and write method. Your concrete implementations have to implement both.
by nesarkvechnep 1y ago
If the filesystem is a trait which has a read and write method. Your concrete implementations have to implement both.
- dwattttt 1y agoSo... 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.