diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-12-15 11:11:57 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-12-15 11:11:57 +0100 |
| commit | ae38be9097bbb32142ef776e77e627ac12379000 (patch) | |
| tree | f365a348d4c77d2d607d37fee3bc65a601d00a64 /src/library/spacing.rs | |
| parent | fe21c4d399d291e75165b664762f0aa8bdc4724a (diff) | |
Set Rules Episode IV: A New Fold
Diffstat (limited to 'src/library/spacing.rs')
| -rw-r--r-- | src/library/spacing.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/library/spacing.rs b/src/library/spacing.rs index f5de8359..4c6c2017 100644 --- a/src/library/spacing.rs +++ b/src/library/spacing.rs @@ -16,9 +16,27 @@ pub fn v(_: &mut EvalContext, args: &mut Args) -> TypResult<Value> { ))) } +/// A single run of text with the same style. +#[derive(Hash)] +pub struct SpacingNode { + /// The kind of spacing. + pub kind: SpacingKind, + /// The rspacing's styles. + pub styles: Styles, +} + +impl Debug for SpacingNode { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + if f.alternate() { + self.styles.fmt(f)?; + } + write!(f, "{:?}", self.kind) + } +} + /// Kinds of spacing. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Spacing { +pub enum SpacingKind { /// A length stated in absolute values and/or relative to the parent's size. Linear(Linear), /// A length that is the fraction of the remaining free space in the parent. @@ -26,7 +44,7 @@ pub enum Spacing { } castable! { - Spacing, + SpacingKind, Expected: "linear or fractional", Value::Length(v) => Self::Linear(v.into()), Value::Relative(v) => Self::Linear(v.into()), |
