cessen / ropey

A utf8 text rope for manipulating and editing large texts.
MIT License
1.04k stars 46 forks source link

`clone_slice(range: Range) -> Rope`? #20

Closed dpc closed 5 years ago

dpc commented 5 years ago

For implementing copy-paste, it is useful to take part of the Rope, as a new Rope. Right now I will just have to clone() and remove prefix and suffix, which is not too bad, but not ideal. :)

cessen commented 5 years ago

Rope implements From<RopeSlice>, so you can just do my_rope.slice(a..b).into().

More generally, both Rope and RopeSlice have many useful standard library trait implementations that let you accomplish things like this efficiently, so pay attention to the impls. :-)

Hope this helps!

dpc commented 5 years ago

That helps a lot! Thank you!