From 4487f8ff9f1363ea090f109309745eed75af3e4e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 29 Dec 2023 17:22:39 +0100 Subject: [PATCH] Rename `TextBuffer::replace` to `replace_with` (#3751) This removes the name conflict with `str::replace`. * Closes https://github.com/emilk/egui/issues/3746 --- crates/egui/src/widgets/text_edit/builder.rs | 4 ++-- crates/egui/src/widgets/text_edit/text_buffer.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 8b80151975f..3d6ecb185f6 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -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 @@ -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 diff --git a/crates/egui/src/widgets/text_edit/text_buffer.rs b/crates/egui/src/widgets/text_edit/text_buffer.rs index a97d264a15c..58f5afd30fa 100644 --- a/crates/egui/src/widgets/text_edit/text_buffer.rs +++ b/crates/egui/src/widgets/text_edit/text_buffer.rs @@ -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); } @@ -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(); } @@ -121,7 +121,7 @@ impl<'a> TextBuffer for Cow<'a, str> { ::clear(self.to_mut()); } - fn replace(&mut self, text: &str) { + fn replace_with(&mut self, text: &str) { *self = Cow::Owned(text.to_owned()); }