diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-04 09:30:44 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-04 11:38:09 +0100 |
| commit | eb951c008beea502042db4a3a0e8d1f8b51f6f52 (patch) | |
| tree | 9856ee4ed0222222669de10e616a580b2a60135e /library/src/base | |
| parent | 33928a00dc58250e24da1dae4e5db17e7b598d70 (diff) | |
Style changes
Diffstat (limited to 'library/src/base')
| -rw-r--r-- | library/src/base/calc.rs | 14 | ||||
| -rw-r--r-- | library/src/base/color.rs | 26 | ||||
| -rw-r--r-- | library/src/base/data.rs | 5 | ||||
| -rw-r--r-- | library/src/base/mod.rs | 8 |
4 files changed, 23 insertions, 30 deletions
diff --git a/library/src/base/calc.rs b/library/src/base/calc.rs index dd37e8e7..355e5c02 100644 --- a/library/src/base/calc.rs +++ b/library/src/base/calc.rs @@ -101,14 +101,12 @@ pub fn mod_(_: &mut Vm, args: &mut Args) -> SourceResult<Value> { (Value::Int(a), Value::Float(b)) => (a as f64, b), (Value::Float(a), Value::Int(b)) => (a, b as f64), (Value::Float(a), Value::Float(b)) => (a, b), - (Value::Int(_), b) | (Value::Float(_), b) => bail!( - span2, - format!("expected integer or float, found {}", b.type_name()) - ), - (a, _) => bail!( - span1, - format!("expected integer or float, found {}", a.type_name()) - ), + (Value::Int(_), b) | (Value::Float(_), b) => { + bail!(span2, format!("expected integer or float, found {}", b.type_name())) + } + (a, _) => { + bail!(span1, format!("expected integer or float, found {}", a.type_name())) + } }; if b == 0.0 { diff --git a/library/src/base/color.rs b/library/src/base/color.rs index 8bb12334..d54911ca 100644 --- a/library/src/base/color.rs +++ b/library/src/base/color.rs @@ -10,20 +10,18 @@ pub fn luma(_: &mut Vm, args: &mut Args) -> SourceResult<Value> { /// Create an RGB(A) color. pub fn rgb(_: &mut Vm, args: &mut Args) -> SourceResult<Value> { - Ok(Value::Color( - if let Some(string) = args.find::<Spanned<EcoString>>()? { - match RgbaColor::from_str(&string.v) { - Ok(color) => color.into(), - Err(msg) => bail!(string.span, msg), - } - } else { - let Component(r) = args.expect("red component")?; - let Component(g) = args.expect("green component")?; - let Component(b) = args.expect("blue component")?; - let Component(a) = args.eat()?.unwrap_or(Component(255)); - RgbaColor::new(r, g, b, a).into() - }, - )) + Ok(Value::Color(if let Some(string) = args.find::<Spanned<EcoString>>()? { + match RgbaColor::from_str(&string.v) { + Ok(color) => color.into(), + Err(msg) => bail!(string.span, msg), + } + } else { + let Component(r) = args.expect("red component")?; + let Component(g) = args.expect("green component")?; + let Component(b) = args.expect("blue component")?; + let Component(a) = args.eat()?.unwrap_or(Component(255)); + RgbaColor::new(r, g, b, a).into() + })) } /// Create a CMYK color. diff --git a/library/src/base/data.rs b/library/src/base/data.rs index 1199056f..67ef2f2c 100644 --- a/library/src/base/data.rs +++ b/library/src/base/data.rs @@ -81,10 +81,7 @@ fn convert_json(value: serde_json::Value) -> Value { /// Format the user-facing JSON error message. fn format_json_error(error: serde_json::Error) -> String { assert!(error.is_syntax() || error.is_eof()); - format!( - "failed to parse json file: syntax error in line {}", - error.line() - ) + format!("failed to parse json file: syntax error in line {}", error.line()) } /// Read structured data from an XML file. diff --git a/library/src/base/mod.rs b/library/src/base/mod.rs index bb1c8c51..f1fdd2b9 100644 --- a/library/src/base/mod.rs +++ b/library/src/base/mod.rs @@ -5,10 +5,10 @@ mod color; mod data; mod string; -pub use calc::*; -pub use color::*; -pub use data::*; -pub use string::*; +pub use self::calc::*; +pub use self::color::*; +pub use self::data::*; +pub use self::string::*; use comemo::Track; use typst::model::{Eval, Route, Scopes, Vm}; |
