Skip to content

Commit

Permalink
Revert "feat: to_cow_string for rope"
Browse files Browse the repository at this point in the history
This reverts commit 20886ec.
  • Loading branch information
SyMind committed Dec 16, 2024
1 parent 20886ec commit 80881bf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion src/cached_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<T> CachedSource<T> {

impl<T: Source + Hash + PartialEq + Eq + 'static> Source for CachedSource<T> {
fn source(&self) -> Cow<str> {
self.get_rope().to_cow_string()
Cow::Owned(self.get_rope().to_string())
}

fn rope(&self) -> Rope<'_> {
Expand Down
14 changes: 0 additions & 14 deletions src/rope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,20 +461,6 @@ impl<'a> Rope<'a> {
}
}
}

/// Converts the rope to Cow<str>.
pub fn to_cow_string(&self) -> Cow<str> {
match &self.repr {
Repr::Light(s) => Cow::Borrowed(s),
Repr::Full(data) => {
let mut s = String::with_capacity(self.len());
for (chunk, _) in data.iter() {
s.push_str(chunk);
}
Cow::Owned(s)
}
}
}
}

impl Hash for Rope<'_> {
Expand Down

0 comments on commit 80881bf

Please sign in to comment.