diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:28:49 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:39:19 +0100 |
| commit | ab43bd802eafe33977a91893907e67553e099569 (patch) | |
| tree | af4dead92b143348f52e2e8f869df3f7dfd7322a /library/src/compute | |
| parent | d6aaae0cea1e79eecd85dc94ab85b9ad8eff48e8 (diff) | |
Renaming and refactoring
Diffstat (limited to 'library/src/compute')
| -rw-r--r-- | library/src/compute/construct.rs | 11 | ||||
| -rw-r--r-- | library/src/compute/foundations.rs | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs index 4d6068a1..a30faf2e 100644 --- a/library/src/compute/construct.rs +++ b/library/src/compute/construct.rs @@ -1,7 +1,6 @@ use std::num::NonZeroI64; use std::str::FromStr; -use ecow::EcoVec; use typst::eval::Regex; use crate::prelude::*; @@ -173,12 +172,12 @@ cast_from_value! { Component, v: i64 => match v { 0 ..= 255 => Self(v as u8), - _ => Err("must be between 0 and 255")?, + _ => Err("number must be between 0 and 255")?, }, v: Ratio => if (0.0 ..= 1.0).contains(&v.get()) { Self((v.get() * 255.0).round() as u8) } else { - Err("must be between 0% and 100%")? + Err("ratio must be between 0% and 100%")? }, } @@ -220,7 +219,7 @@ cast_from_value! { v: Ratio => if (0.0 ..= 1.0).contains(&v.get()) { Self((v.get() * 255.0).round() as u8) } else { - Err("must be between 0% and 100%")? + Err("ratio must be between 0% and 100%")? }, } @@ -258,14 +257,14 @@ pub fn symbol( #[variadic] variants: Vec<Spanned<Variant>>, ) -> Value { - let mut list = EcoVec::new(); + let mut list = Vec::new(); for Spanned { v, span } in variants { if list.iter().any(|(prev, _)| &v.0 == prev) { bail!(span, "duplicate variant"); } list.push((v.0, v.1)); } - Value::Symbol(Symbol::runtime(list)) + Value::Symbol(Symbol::runtime(list.into_boxed_slice())) } /// A value that can be cast to a symbol. diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs index 8b148c85..d5397e60 100644 --- a/library/src/compute/foundations.rs +++ b/library/src/compute/foundations.rs @@ -134,5 +134,5 @@ pub fn eval( source: Spanned<String>, ) -> Value { let Spanned { v: text, span } = source; - typst::eval::eval_code_str(vm.world(), &text, span)? + typst::eval::eval_string(vm.world(), &text, span)? } |
