Closed hawkw closed 7 years ago
Okay @rachlmac, finishing these implementations should be pretty simple.
To get you started, the naïve solution for Extend<char>
would just be to consume each character from the iterator one-by-one and add them to the end of the Rope
. You could do that with a for
... in
loop over the iterator.
You might get better performance out of collect
ing elements into a String
and then just appending that onto the end of the Rope
, as it would involve creating fewer intermediate ropes, and would only trigger one rebalance.
Implementing Extend<String>
should be more or less the same, but with a couple types changed. We'll get to the implementation for borrowed references (&'a str
and &'a char
) tomorrow.
Rope
should provide implementations of thestd::iter::Extend
trait, just likeString
.We will want to implement
Extend<char>
,Extend<&'a char>
,Extend<&'a str>
andExtend<String>
, just likeString
does. Should consider implementingExtend<Rope>
as well?