summaryrefslogtreecommitdiffstats
path: root/graphics/src/text
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-09-01 04:14:06 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-09-01 04:14:06 +0200
commit6758de2b4348d8990205721027524cf87a9db128 (patch)
treeec05c09a43e082f2f8dd61aacc45499d4057d986 /graphics/src/text
parent51e69d7040c943aad8453bc03031c75b4cb302bb (diff)
downloadiced-6758de2b4348d8990205721027524cf87a9db128.tar.gz
iced-6758de2b4348d8990205721027524cf87a9db128.tar.bz2
iced-6758de2b4348d8990205721027524cf87a9db128.zip
Fix `Default` implementation for `Paragraph`
Diffstat (limited to 'graphics/src/text')
-rw-r--r--graphics/src/text/paragraph.rs40
1 files changed, 23 insertions, 17 deletions
diff --git a/graphics/src/text/paragraph.rs b/graphics/src/text/paragraph.rs
index 8e8907f9..d99b8412 100644
--- a/graphics/src/text/paragraph.rs
+++ b/graphics/src/text/paragraph.rs
@@ -7,7 +7,7 @@ use crate::text::{self, FontSystem};
use std::fmt;
use std::sync::{self, Arc};
-#[derive(Clone, PartialEq, Default)]
+#[derive(Clone, PartialEq)]
pub struct Paragraph(Option<Arc<Internal>>);
struct Internal {
@@ -195,6 +195,28 @@ impl core::text::Paragraph for Paragraph {
}
}
+impl Default for Paragraph {
+ fn default() -> Self {
+ Self(Some(Arc::new(Internal::default())))
+ }
+}
+
+impl fmt::Debug for Paragraph {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let paragraph = self.internal();
+
+ f.debug_struct("Paragraph")
+ .field("content", &paragraph.content)
+ .field("font", &paragraph.font)
+ .field("shaping", &paragraph.shaping)
+ .field("horizontal_alignment", &paragraph.horizontal_alignment)
+ .field("vertical_alignment", &paragraph.vertical_alignment)
+ .field("bounds", &paragraph.bounds)
+ .field("min_bounds", &paragraph.min_bounds)
+ .finish()
+ }
+}
+
impl PartialEq for Internal {
fn eq(&self, other: &Self) -> bool {
self.content == other.content
@@ -226,22 +248,6 @@ impl Default for Internal {
}
}
-impl fmt::Debug for Paragraph {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- let paragraph = self.internal();
-
- f.debug_struct("Paragraph")
- .field("content", &paragraph.content)
- .field("font", &paragraph.font)
- .field("shaping", &paragraph.shaping)
- .field("horizontal_alignment", &paragraph.horizontal_alignment)
- .field("vertical_alignment", &paragraph.vertical_alignment)
- .field("bounds", &paragraph.bounds)
- .field("min_bounds", &paragraph.min_bounds)
- .finish()
- }
-}
-
#[derive(Debug, Clone)]
pub struct Weak {
raw: sync::Weak<Internal>,