summaryrefslogtreecommitdiff
path: root/library/src/layout/repeat.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-29 13:37:25 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-29 14:18:13 +0100
commit0efe669278a5e1c3f2985eba2f3360e91159c54a (patch)
tree502712857c48f0decb5e698257c0a96d358a436e /library/src/layout/repeat.rs
parent836692e73cff0356e409a9ba5b4887b86809d4ca (diff)
Reorganize library and tests
Diffstat (limited to 'library/src/layout/repeat.rs')
-rw-r--r--library/src/layout/repeat.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/library/src/layout/repeat.rs b/library/src/layout/repeat.rs
new file mode 100644
index 00000000..d9323e1d
--- /dev/null
+++ b/library/src/layout/repeat.rs
@@ -0,0 +1,25 @@
+use crate::prelude::*;
+
+/// Repeats content to fill a line.
+#[derive(Debug, Hash)]
+pub struct RepeatNode(pub Content);
+
+#[node(Layout, Inline)]
+impl RepeatNode {
+ fn construct(_: &Vm, args: &mut Args) -> SourceResult<Content> {
+ Ok(Self(args.expect("body")?).pack())
+ }
+}
+
+impl Layout for RepeatNode {
+ fn layout(
+ &self,
+ world: Tracked<dyn World>,
+ styles: StyleChain,
+ regions: &Regions,
+ ) -> SourceResult<Fragment> {
+ self.0.layout(world, styles, regions)
+ }
+}
+
+impl Inline for RepeatNode {}