From 0a087cd28bbee5fcdffbb9d49b0ba9f413ad7f92 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 24 Jan 2020 16:23:57 +0100 Subject: =?UTF-8?q?Reorganize=20modules=20=F0=9F=A7=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/func/values.rs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/syntax/func/values.rs') 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 Value for Defaultable { } } -impl Value for Direction { - type Output = Self; - - fn parse(expr: Spanned) -> Result { - 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) -> Result { + 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")) }) } } -- cgit v1.2.3