Fix Default implementation for Paragraph
This commit is contained in:
parent
51e69d7040
commit
6758de2b43
1 changed files with 23 additions and 17 deletions
|
|
@ -7,7 +7,7 @@ use crate::text::{self, FontSystem};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::{self, Arc};
|
use std::sync::{self, Arc};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Default)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct Paragraph(Option<Arc<Internal>>);
|
pub struct Paragraph(Option<Arc<Internal>>);
|
||||||
|
|
||||||
struct 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 {
|
impl PartialEq for Internal {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.content == other.content
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Weak {
|
pub struct Weak {
|
||||||
raw: sync::Weak<Internal>,
|
raw: sync::Weak<Internal>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue