Skip to content

Commit 07c64bc

Browse files
committed
Do not require Copy for text StyleSheet::Style
For most widgets, `Style` only requires `Default`. A few require `Clone`. Only this one requires `Copy`. Some of the types in the default theme has a custom variant requiring `Box<dyn Trait>`, or `Rc<dyn Trait>` to provide `Clone`, but this isn't possible if `Copy` is required. It would be good to also address the inconsistency of requiring `Clone` in some places and not others. This removes `style/src/text.rs` which is unused in this branch and thus confusing. If there's a reason to keep it, that can be removed from the change.
1 parent c31ab8e commit 07c64bc

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

core/src/widget/text.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ where
153153
&self.content,
154154
self.size,
155155
self.font,
156-
theme.appearance(self.style),
156+
theme.appearance(self.style.clone()),
157157
self.horizontal_alignment,
158158
self.vertical_alignment,
159159
);
@@ -233,7 +233,7 @@ where
233233
horizontal_alignment: self.horizontal_alignment,
234234
vertical_alignment: self.vertical_alignment,
235235
font: self.font,
236-
style: self.style,
236+
style: self.style.clone(),
237237
}
238238
}
239239
}
@@ -261,7 +261,7 @@ where
261261
/// The style sheet of some text.
262262
pub trait StyleSheet {
263263
/// The supported style of the [`StyleSheet`].
264-
type Style: Default + Copy;
264+
type Style: Default + Clone;
265265

266266
/// Produces the [`Appearance`] of some text.
267267
fn appearance(&self, style: Self::Style) -> Appearance;

style/src/text.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

style/src/theme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ impl scrollable::StyleSheet for Theme {
980980
}
981981

982982
/// The style of text.
983-
#[derive(Clone, Copy, Default)]
983+
#[derive(Clone, Default)]
984984
pub enum Text {
985985
/// The default style.
986986
#[default]

0 commit comments

Comments
 (0)