diff options
author | 2023-09-01 04:14:06 +0200 | |
---|---|---|
committer | 2023-09-01 04:14:06 +0200 | |
commit | 6758de2b4348d8990205721027524cf87a9db128 (patch) | |
tree | ec05c09a43e082f2f8dd61aacc45499d4057d986 /graphics/src/text | |
parent | 51e69d7040c943aad8453bc03031c75b4cb302bb (diff) | |
download | iced-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.rs | 40 |
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", ¶graph.content) + .field("font", ¶graph.font) + .field("shaping", ¶graph.shaping) + .field("horizontal_alignment", ¶graph.horizontal_alignment) + .field("vertical_alignment", ¶graph.vertical_alignment) + .field("bounds", ¶graph.bounds) + .field("min_bounds", ¶graph.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", ¶graph.content) - .field("font", ¶graph.font) - .field("shaping", ¶graph.shaping) - .field("horizontal_alignment", ¶graph.horizontal_alignment) - .field("vertical_alignment", ¶graph.vertical_alignment) - .field("bounds", ¶graph.bounds) - .field("min_bounds", ¶graph.min_bounds) - .finish() - } -} - #[derive(Debug, Clone)] pub struct Weak { raw: sync::Weak<Internal>, |