diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-01-11 10:11:14 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-01-11 10:11:14 +0100 |
| commit | b1e956419d94a0c3876891b3d6a4976cc4a3ab09 (patch) | |
| tree | 20e557d9ac6145159a2480f4cd0c3c775083f394 /src/style.rs | |
| parent | a75ddd2c9356da85b155f5c52fd064c15e6f81b3 (diff) | |
Re-engineer tokenization 🚿
Diffstat (limited to 'src/style.rs')
| -rw-r--r-- | src/style.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/style.rs b/src/style.rs index e552a63d..35de5da1 100644 --- a/src/style.rs +++ b/src/style.rs @@ -3,7 +3,6 @@ use toddle::query::{FontFallbackTree, FontVariant, FontStyle, FontWeight}; use crate::size::{Size, Size2D, SizeBox, ValueBox, PSize}; -use crate::syntax::ParseResult; /// Defines properties of pages and text. @@ -157,7 +156,7 @@ pub struct Paper { impl Paper { /// The paper with the given name. - pub fn from_name(name: &str) -> ParseResult<Paper> { + pub fn from_name(name: &str) -> Option<Paper> { parse_paper(name) } } @@ -193,11 +192,11 @@ macro_rules! papers { class: $class, };)* - fn parse_paper(paper: &str) -> ParseResult<Paper> { - Ok(match paper.to_lowercase().as_str() { - $($($patterns)* => $var,)* - _ => error!("unknown paper size: `{}`", paper), - }) + fn parse_paper(paper: &str) -> Option<Paper> { + match paper.to_lowercase().as_str() { + $($($patterns)* => Some($var),)* + _ => None, + } } }; } |
