Skip to content

Commit

Permalink
Rename TextBuffer::replace to replace_with (#3751)
Browse files Browse the repository at this point in the history
This removes the name conflict with `str::replace`.

* Closes #3746
  • Loading branch information
emilk authored Dec 29, 2023
1 parent 239ade9 commit 4487f8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ fn events(
.lock()
.undo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned()))
{
text.replace(undo_txt);
text.replace_with(undo_txt);
Some(*undo_ccursor_range)
} else {
None
Expand All @@ -1015,7 +1015,7 @@ fn events(
.lock()
.redo(&(cursor_range.as_ccursor_range(), text.as_str().to_owned()))
{
text.replace(redo_txt);
text.replace_with(redo_txt);
Some(*redo_ccursor_range)
} else {
None
Expand Down
6 changes: 3 additions & 3 deletions crates/egui/src/widgets/text_edit/text_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub trait TextBuffer {
}

/// Replaces all contents of this string with `text`
fn replace(&mut self, text: &str) {
fn replace_with(&mut self, text: &str) {
self.clear();
self.insert_text(text, 0);
}
Expand Down Expand Up @@ -91,7 +91,7 @@ impl TextBuffer for String {
self.clear();
}

fn replace(&mut self, text: &str) {
fn replace_with(&mut self, text: &str) {
*self = text.to_owned();
}

Expand Down Expand Up @@ -121,7 +121,7 @@ impl<'a> TextBuffer for Cow<'a, str> {
<String as TextBuffer>::clear(self.to_mut());
}

fn replace(&mut self, text: &str) {
fn replace_with(&mut self, text: &str) {
*self = Cow::Owned(text.to_owned());
}

Expand Down

0 comments on commit 4487f8f

Please sign in to comment.