Do something about rope `Index` implementations
Opened this issue · 3 comments
We have all of these empty ops::Index
impl blocks for Rope
s. It would be nice if something could be done about these.
Unfortunately, figuring out the correct return type for these is gonna be a challenge. Having them return string slices is impossible, because the sliced index might span multiple nodes.
Having them return RopeSlice
s is equally hard, since the ops::Index
trait requires that the return type of indexing must be a borrow, and an owned RopeSlice
isn't borrowed but resembles a borrow (if that makes sense). See http://stackoverflow.com/questions/30083833/why-does-the-borrow-trait-require-the-borrowed-type-to-be-a-reference
Possibly these impls should just be deleted and we should use Rope.slice()
exclusively.
There might be a way to get around Rust's lack of HKTs using the for<'a>
qualifier in a type, as discussed here. I'm not terribly familiar with the semantics of this so I'd have to do some research.