summaryrefslogtreecommitdiffstats
path: root/lazy/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-11-03 03:12:23 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-03 03:12:23 +0100
commit231d2fd8454eb9d24ba970131d4d7339cc0c8d51 (patch)
treeff21ac61a872b3581bc0ef385bca99c5fd6d3c0a /lazy/src/lib.rs
parent3b8669ae94d4d17d3bac0b8ce6d1b019e373253e (diff)
parent415978b80771fdd065b65e115d1dcc6aaa9d792c (diff)
downloadiced-231d2fd8454eb9d24ba970131d4d7339cc0c8d51.tar.gz
iced-231d2fd8454eb9d24ba970131d4d7339cc0c8d51.tar.bz2
iced-231d2fd8454eb9d24ba970131d4d7339cc0c8d51.zip
Merge pull request #1400 from nicksenger/lazy/cached
`Lazy` widget
Diffstat (limited to 'lazy/src/lib.rs')
-rw-r--r--lazy/src/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/lazy/src/lib.rs b/lazy/src/lib.rs
index 3827746c..f49fe4b6 100644
--- a/lazy/src/lib.rs
+++ b/lazy/src/lib.rs
@@ -17,15 +17,30 @@
clippy::type_complexity
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
+mod lazy;
+
pub mod component;
pub mod responsive;
pub use component::Component;
+pub use lazy::Lazy;
pub use responsive::Responsive;
mod cache;
use iced_native::{Element, Size};
+use std::hash::Hash;
+
+pub fn lazy<'a, Message, Renderer, Dependency, View>(
+ dependency: Dependency,
+ view: impl Fn() -> View + 'a,
+) -> Lazy<'a, Message, Renderer, Dependency, View>
+where
+ Dependency: Hash + 'a,
+ View: Into<Element<'static, Message, Renderer>>,
+{
+ Lazy::new(dependency, view)
+}
/// Turns an implementor of [`Component`] into an [`Element`] that can be
/// embedded in any application.