an-cabal/an-rope

Consider refactoring Rope::insert family to be more general

Opened this issue · 0 comments

hawkw commented

Currently, we have a number of different methods in the Rope::insert family depending on the type of the argument - insert_str, insert, insert_rope etc. I don't think this is good API design, personally, and it should be more or less trivial to rewrite these into one method, that looks like this:

pub fn insert<I>(&mut self, other: I> 
where I: convert::Into<Rope> {
  // ...
}

and then providing convert::Into<Rope> implementations for char (we already have it for String and &str).

The downside to this, though, is that we'd no longer match std::String's API exactly, since it provides separate insert and insert_str methods. @cjm00, what do you think?