From 0854fe9938548f2d316e0873748ed6f7a36a5163 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Mon, 9 Dec 2024 14:55:01 -0500 Subject: [PATCH] test: it_composes_from_iter --- src/composer.rs | 26 ++++++++++++++++++++++++++ src/data.rs | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/composer.rs b/src/composer.rs index 08d8ad2..49ebbb3 100644 --- a/src/composer.rs +++ b/src/composer.rs @@ -643,6 +643,32 @@ mod tests { assert_eq!(x.get(), 2); } + #[test] + fn it_composes_from_iter() { + #[derive(Data)] + #[actuate(path = "crate")] + struct Wrap { + x: Rc>, + } + + impl Compose for Wrap { + fn compose(cx: crate::Scope) -> impl Compose { + compose::from_iter(0..2, move |_| Counter { + x: cx.me().x.clone(), + }) + } + } + + let x = Rc::new(Cell::new(0)); + let mut composer = Composer::new(Wrap { x: x.clone() }); + + composer.try_compose().unwrap(); + assert_eq!(x.get(), 2); + + composer.try_compose().unwrap(); + assert_eq!(x.get(), 4); + } + #[test] fn it_composes_memo() { #[derive(Data)] diff --git a/src/data.rs b/src/data.rs index 086a36e..f55bb95 100644 --- a/src/data.rs +++ b/src/data.rs @@ -55,7 +55,7 @@ //! ``` use crate::{compose::DynCompose, HashMap}; -use core::{error::Error, future::Future, pin::Pin}; +use core::{error::Error, future::Future, ops::Range, pin::Pin}; pub use actuate_macros::{data, Data}; @@ -114,6 +114,8 @@ unsafe impl Data for Result {} unsafe impl Data for Pin {} +unsafe impl Data for Range {} + unsafe impl Data for Box {} unsafe impl Data for Box + '_> {}