Remove trait redundancy in text_editor

This commit is contained in:
Héctor Ramón Jiménez 2025-11-21 00:59:52 +01:00
parent e20fee7956
commit 96be0b5470
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -170,7 +170,7 @@ impl<'a, Highlighter, Message, Theme, Renderer>
TextEditor<'a, Highlighter, Message, Theme, Renderer> TextEditor<'a, Highlighter, Message, Theme, Renderer>
where where
Highlighter: text::Highlighter, Highlighter: text::Highlighter,
Theme: Catalog + 'static + PartialEq, Theme: Catalog + 'static,
Renderer: text::Renderer, Renderer: text::Renderer,
{ {
/// Sets the placeholder of the [`TextEditor`]. /// Sets the placeholder of the [`TextEditor`].
@ -508,7 +508,7 @@ where
/// The state of a [`TextEditor`]. /// The state of a [`TextEditor`].
#[derive(Debug)] #[derive(Debug)]
pub struct State<Highlighter: text::Highlighter, Theme: PartialEq> { pub struct State<Highlighter: text::Highlighter, Theme> {
focus: Option<Focus>, focus: Option<Focus>,
preedit: Option<input_method::Preedit>, preedit: Option<input_method::Preedit>,
last_click: Option<mouse::Click>, last_click: Option<mouse::Click>,
@ -548,17 +548,15 @@ impl Focus {
} }
} }
impl<Highlighter: text::Highlighter, Theme: PartialEq + 'static> impl<Highlighter: text::Highlighter, Theme> State<Highlighter, Theme> {
State<Highlighter, Theme>
{
/// Returns whether the [`TextEditor`] is currently focused or not. /// Returns whether the [`TextEditor`] is currently focused or not.
pub fn is_focused(&self) -> bool { pub fn is_focused(&self) -> bool {
self.focus.is_some() self.focus.is_some()
} }
} }
impl<Highlighter: text::Highlighter, Theme: PartialEq + 'static> impl<Highlighter: text::Highlighter, Theme> operation::Focusable
operation::Focusable for State<Highlighter, Theme> for State<Highlighter, Theme>
{ {
fn is_focused(&self) -> bool { fn is_focused(&self) -> bool {
self.focus.is_some() self.focus.is_some()
@ -577,7 +575,7 @@ impl<Highlighter, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
for TextEditor<'_, Highlighter, Message, Theme, Renderer> for TextEditor<'_, Highlighter, Message, Theme, Renderer>
where where
Highlighter: text::Highlighter, Highlighter: text::Highlighter,
Theme: Catalog + 'static + PartialEq + Clone, Theme: Catalog + 'static,
Renderer: text::Renderer, Renderer: text::Renderer,
{ {
fn tag(&self) -> widget::tree::Tag { fn tag(&self) -> widget::tree::Tag {
@ -789,9 +787,9 @@ where
}, },
Update::Binding(binding) => { Update::Binding(binding) => {
fn apply_binding< fn apply_binding<
T: PartialEq + 'static,
H: text::Highlighter, H: text::Highlighter,
R: text::Renderer, R: text::Renderer,
T,
Message, Message,
>( >(
binding: Binding<Message>, binding: Binding<Message>,
@ -1091,7 +1089,7 @@ impl<'a, Highlighter, Message, Theme, Renderer>
where where
Highlighter: text::Highlighter, Highlighter: text::Highlighter,
Message: 'a, Message: 'a,
Theme: Catalog + 'static + PartialEq + Clone, Theme: Catalog + 'static,
Renderer: text::Renderer, Renderer: text::Renderer,
{ {
fn from( fn from(
@ -1247,7 +1245,7 @@ enum Ime {
} }
impl<Message> Update<Message> { impl<Message> Update<Message> {
fn from_event<H: Highlighter, T: PartialEq + 'static>( fn from_event<H: Highlighter, T>(
event: &Event, event: &Event,
state: &State<H, T>, state: &State<H, T>,
bounds: Rectangle, bounds: Rectangle,
@ -1406,7 +1404,7 @@ pub struct Style {
} }
/// The theme catalog of a [`TextEditor`]. /// The theme catalog of a [`TextEditor`].
pub trait Catalog { pub trait Catalog: PartialEq + Clone {
/// The item class of the [`Catalog`]. /// The item class of the [`Catalog`].
type Class<'a>; type Class<'a>;