summaryrefslogtreecommitdiff
path: root/src/syntax/func/values.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax/func/values.rs')
-rw-r--r--src/syntax/func/values.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/syntax/func/values.rs b/src/syntax/func/values.rs
index b29b9726..a767aef6 100644
--- a/src/syntax/func/values.rs
+++ b/src/syntax/func/values.rs
@@ -1,12 +1,13 @@
+use std::fmt::{self, Display, Formatter};
use std::marker::PhantomData;
use toddle::query::{FontStyle, FontWeight};
use crate::layout::prelude::*;
-use crate::size::ScaleSize;
+use crate::size::{Size, ScaleSize};
use crate::style::Paper;
use super::*;
-use AlignmentValue::*;
+use self::AlignmentValue::*;
pub trait Value {
@@ -76,20 +77,6 @@ impl<T: Value> Value for Defaultable<T> {
}
}
-impl Value for Direction {
- type Output = Self;
-
- fn parse(expr: Spanned<Expr>) -> Result<Self::Output, Error> {
- Ok(match Ident::parse(expr)?.as_str() {
- "left-to-right" | "ltr" | "LTR" => Direction::LeftToRight,
- "right-to-left" | "rtl" | "RTL" => Direction::RightToLeft,
- "top-to-bottom" | "ttb" | "TTB" => Direction::TopToBottom,
- "bottom-to-top" | "btt" | "BTT" => Direction::BottomToTop,
- other => return Err(err!("invalid direction"))
- })
- }
-}
-
impl Value for FontStyle {
type Output = Self;
@@ -134,6 +121,20 @@ impl Value for Paper {
}
}
+impl Value for Direction {
+ type Output = Self;
+
+ fn parse(expr: Spanned<Expr>) -> Result<Self::Output, Error> {
+ Ok(match Ident::parse(expr)?.as_str() {
+ "left-to-right" | "ltr" | "LTR" => LeftToRight,
+ "right-to-left" | "rtl" | "RTL" => RightToLeft,
+ "top-to-bottom" | "ttb" | "TTB" => TopToBottom,
+ "bottom-to-top" | "btt" | "BTT" => BottomToTop,
+ _ => return Err(err!("invalid direction"))
+ })
+ }
+}
+
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum AlignmentValue {
Align(Alignment),
@@ -203,7 +204,7 @@ impl Value for AlignmentValue {
"top" => Top,
"right" => Right,
"bottom" => Bottom,
- other => return Err(err!("invalid alignment"))
+ _ => return Err(err!("invalid alignment"))
})
}
}