summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
Diffstat (limited to 'src/library')
-rw-r--r--src/library/boxed.rs8
-rw-r--r--src/library/color.rs23
-rw-r--r--src/library/font.rs8
-rw-r--r--src/library/page.rs2
-rw-r--r--src/library/spacing.rs2
5 files changed, 23 insertions, 20 deletions
diff --git a/src/library/boxed.rs b/src/library/boxed.rs
index 5c727bb6..5d98760f 100644
--- a/src/library/boxed.rs
+++ b/src/library/boxed.rs
@@ -1,12 +1,16 @@
-use crate::length::ScaleLength;
use super::*;
+use crate::length::ScaleLength;
/// `box`: Layouts its contents into a box.
///
/// # Keyword arguments
/// - `width`: The width of the box (length of relative to parent's width).
/// - `height`: The height of the box (length of relative to parent's height).
-pub async fn boxed(_: Span, mut args: TableValue, mut ctx: LayoutContext<'_>) -> Pass<Value> {
+pub async fn boxed(
+ _: Span,
+ mut args: TableValue,
+ mut ctx: LayoutContext<'_>,
+) -> Pass<Value> {
let mut f = Feedback::new();
let content = args.take::<SyntaxTree>().unwrap_or(SyntaxTree::new());
diff --git a/src/library/color.rs b/src/library/color.rs
index 12bebdc9..0d7e8535 100644
--- a/src/library/color.rs
+++ b/src/library/color.rs
@@ -1,5 +1,5 @@
-use crate::color::RgbaColor;
use super::*;
+use crate::color::RgbaColor;
/// `rgb`: Create an RGB(A) color.
pub async fn rgb(span: Span, mut args: TableValue, _: LayoutContext<'_>) -> Pass<Value> {
@@ -11,20 +11,17 @@ pub async fn rgb(span: Span, mut args: TableValue, _: LayoutContext<'_>) -> Pass
let a = args.take::<Spanned<f64>>();
let mut clamp = |component: Option<Spanned<f64>>, default| {
- component.map(|c| {
- if c.v < 0.0 || c.v > 255.0 {
- error!(@f, c.span, "should be between 0 and 255")
- }
- c.v.min(255.0).max(0.0).round() as u8
- }).unwrap_or(default)
+ component
+ .map(|c| {
+ if c.v < 0.0 || c.v > 255.0 {
+ error!(@f, c.span, "should be between 0 and 255")
+ }
+ c.v.min(255.0).max(0.0).round() as u8
+ })
+ .unwrap_or(default)
};
- let color = RgbaColor::new(
- clamp(r, 0),
- clamp(g, 0),
- clamp(b, 0),
- clamp(a, 255),
- );
+ let color = RgbaColor::new(clamp(r, 0), clamp(g, 0), clamp(b, 0), clamp(a, 255));
args.unexpected(&mut f);
Pass::new(Value::Color(color), f)
diff --git a/src/library/font.rs b/src/library/font.rs
index ae059512..e3caeded 100644
--- a/src/library/font.rs
+++ b/src/library/font.rs
@@ -1,7 +1,7 @@
use fontdock::{FontStyle, FontWeight, FontWidth};
-use crate::length::ScaleLength;
use super::*;
+use crate::length::ScaleLength;
/// `font`: Configure the font.
///
@@ -35,7 +35,8 @@ pub async fn font(_: Span, mut args: TableValue, ctx: LayoutContext<'_>) -> Pass
}
}
- let list: Vec<_> = args.take_all_num_vals::<StringLike>()
+ let list: Vec<_> = args
+ .take_all_num_vals::<StringLike>()
.map(|s| s.to_lowercase())
.collect();
@@ -57,7 +58,8 @@ pub async fn font(_: Span, mut args: TableValue, ctx: LayoutContext<'_>) -> Pass
}
for (class, mut table) in args.take_all_str::<TableValue>() {
- let fallback = table.take_all_num_vals::<StringLike>()
+ let fallback = table
+ .take_all_num_vals::<StringLike>()
.map(|s| s.to_lowercase())
.collect();
diff --git a/src/library/page.rs b/src/library/page.rs
index f6f9c1c8..ee551064 100644
--- a/src/library/page.rs
+++ b/src/library/page.rs
@@ -1,6 +1,6 @@
+use super::*;
use crate::length::{Length, ScaleLength};
use crate::paper::{Paper, PaperClass};
-use super::*;
/// `page`: Configure pages.
///
diff --git a/src/library/spacing.rs b/src/library/spacing.rs
index 91049db8..8b2f1622 100644
--- a/src/library/spacing.rs
+++ b/src/library/spacing.rs
@@ -1,6 +1,6 @@
+use super::*;
use crate::layout::SpacingKind;
use crate::length::ScaleLength;
-use super::*;
/// `h`: Add horizontal spacing.
///