Skip to content

Commit 82eeea3

Browse files
committed
style: apply rustfmt formatting across test framework and flex_box
cargo fmt pass: multi-line chaining, assert_eq reformatting, getter line breaks, trailing newline cleanup, flex_box length_sum/map formatting. No logic changes.
1 parent c9507f7 commit 82eeea3

5 files changed

Lines changed: 35 additions & 22 deletions

File tree

float-pigment-forest/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ fn main() {
4242
let html = fs::read_to_string(&abs).unwrap_or_default();
4343
let ignore = html.contains("data-ignore=\"true\"");
4444
let body = translate_html(&html);
45-
by_topic.entry(topic).or_default().push((name, body, ignore));
45+
by_topic
46+
.entry(topic)
47+
.or_default()
48+
.push((name, body, ignore));
4649
}
4750
}
4851

float-pigment-forest/tests/custom/imperative_api_check.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ fn imperative_grid_equivalent_to_from_str() {
3939

4040
// Helper: append a div with text content under parent. Returns the div
4141
// handle so we can assert against it.
42-
fn append_div_with_text(
43-
ctx: &mut TestCtx,
44-
parent: NodeHandle,
45-
text: &str,
46-
) -> NodeHandle {
42+
fn append_div_with_text(ctx: &mut TestCtx, parent: NodeHandle, text: &str) -> NodeHandle {
4743
let div = ctx.create_node("div");
4844
let t = ctx.create_text(text);
4945
ctx.append(div, t);
@@ -58,7 +54,7 @@ fn imperative_grid_equivalent_to_from_str() {
5854

5955
// Row 2 (template row height 40px)
6056
let n4 = append_div_with_text(&mut ctx, n0, "content1"); // left=0
61-
// content2 has an explicit inline style overriding width/height.
57+
// content2 has an explicit inline style overriding width/height.
6258
let n5 = ctx.create_node("div");
6359
ctx.set_style(n5, "width: 23px; height: 23px");
6460
let t5 = ctx.create_text("content2");
@@ -84,7 +80,11 @@ fn imperative_grid_equivalent_to_from_str() {
8480
// Row 2 — 40px template row, except content2 which sets its own height.
8581
assert_eq!(ctx.height(n4), 40.0, "content1 height");
8682
assert_eq!(ctx.left(n4), 0.0, "content1 left");
87-
assert_eq!(ctx.height(n5), 23.0, "content2 height (inline style override)");
83+
assert_eq!(
84+
ctx.height(n5),
85+
23.0,
86+
"content2 height (inline style override)"
87+
);
8888
assert_eq!(ctx.left(n5), 250.0, "content2 left");
8989
assert_eq!(ctx.height(n6), 40.0, "content3 height");
9090
assert_eq!(ctx.left(n6), 350.0, "content3 left");

float-pigment-forest/tests/custom/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ mod css_inline;
33
mod css_margin;
44
mod css_margin_collapse;
55
mod imperative_api_check;
6-
7-
8-

float-pigment-forest/tests/mod.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,28 @@ impl TestCtx {
308308
// ===== 命令式 getters(layout_imperative 之后读节点的尺寸/位置/margin)=====
309309

310310
pub fn width(&self, n: NodeHandle) -> f32 {
311-
unsafe { (*self.imperative_built[n.0]).layout_position().width.to_f32() }
311+
unsafe {
312+
(*self.imperative_built[n.0])
313+
.layout_position()
314+
.width
315+
.to_f32()
316+
}
312317
}
313318
pub fn height(&self, n: NodeHandle) -> f32 {
314-
unsafe { (*self.imperative_built[n.0]).layout_position().height.to_f32() }
319+
unsafe {
320+
(*self.imperative_built[n.0])
321+
.layout_position()
322+
.height
323+
.to_f32()
324+
}
315325
}
316326
pub fn left(&self, n: NodeHandle) -> f32 {
317-
unsafe { (*self.imperative_built[n.0]).layout_position().left.to_f32() }
327+
unsafe {
328+
(*self.imperative_built[n.0])
329+
.layout_position()
330+
.left
331+
.to_f32()
332+
}
318333
}
319334
pub fn top(&self, n: NodeHandle) -> f32 {
320335
unsafe { (*self.imperative_built[n.0]).layout_position().top.to_f32() }

float-pigment-layout/src/algo/flex_box.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,12 @@ impl<T: LayoutTreeNode> FlexBox<T> for LayoutUnit<T> {
538538
{
539539
requested
540540
} else {
541-
let total_main_axis_gap_all_lines: T::Length = length_sum(
542-
flex_lines
543-
.iter()
544-
.map(|l| sum_axis_gaps(
545-
main_axis_gap::<T>(dir, style, node, &requested_inner_size),
546-
l.items.len(),
547-
)),
548-
);
541+
let total_main_axis_gap_all_lines: T::Length = length_sum(flex_lines.iter().map(|l| {
542+
sum_axis_gaps(
543+
main_axis_gap::<T>(dir, style, node, &requested_inner_size),
544+
l.items.len(),
545+
)
546+
}));
549547
let max_content_size: T::Length = total_main_axis_gap_all_lines
550548
+ length_sum(
551549
flex_lines

0 commit comments

Comments
 (0)