cairo
cairo copied to clipboard
Split len and is_empty methods to a different trait
This splits the len and is_empty methods to a different trait (which I called Container, but that name is not something I'm particularly attached to).
This will make it easier to write generic algorithms, since we can know expect 'container' types that implement Index and Container instead of having to rely on specific types.
Unfortunately, there are still some awkward bits:
- Despite requiring Container as a super-trait of ArrayTrait and SpanTrait, the super-trait is not automatically put in scope for inference, and so needs to be manually imported. This is rather clunky and would break backwards-compatibility in a bad way. I am not sure off-hand how easy it would be to fix inference for this case.
- I'm not entirely sure why Span
len/is_emptywasn't implemented for snapshots ? - this means we cannot use the recently added
generate_traitmacro.
IMO get and at should be removed in favour of just the indexing trait.
At this point, all that remains is to split off append / pop_front / pop_back in various traits. I'm not sure it's a good idea to bundle these too much.