From 561b754e91999406d5d43149fb59bf4df2b44c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 5 Sep 2024 14:46:11 +0200 Subject: [PATCH] Flag `lazy` feature types directly Co-authored-by: JL710 --- widget/src/lazy.rs | 1 + widget/src/lazy/component.rs | 1 + widget/src/lazy/helpers.rs | 5 +++-- widget/src/lazy/responsive.rs | 1 + widget/src/lib.rs | 3 --- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/widget/src/lazy.rs b/widget/src/lazy.rs index 4bcf86289c..883a2f6556 100644 --- a/widget/src/lazy.rs +++ b/widget/src/lazy.rs @@ -29,6 +29,7 @@ use std::hash::{Hash, Hasher as H}; use std::rc::Rc; /// A widget that only rebuilds its contents when necessary. +#[cfg(feature = "lazy")] #[allow(missing_debug_implementations)] pub struct Lazy<'a, Message, Theme, Renderer, Dependency, View> { dependency: Dependency, diff --git a/widget/src/lazy/component.rs b/widget/src/lazy/component.rs index 1bf04195e9..1ec07e3721 100644 --- a/widget/src/lazy/component.rs +++ b/widget/src/lazy/component.rs @@ -30,6 +30,7 @@ use std::rc::Rc; /// /// Additionally, a [`Component`] is capable of producing a `Message` to notify /// the parent application of any relevant interactions. +#[cfg(feature = "lazy")] pub trait Component { /// The internal state of this [`Component`]. type State: Default; diff --git a/widget/src/lazy/helpers.rs b/widget/src/lazy/helpers.rs index 4d0776ca0d..862b251e99 100644 --- a/widget/src/lazy/helpers.rs +++ b/widget/src/lazy/helpers.rs @@ -1,9 +1,10 @@ use crate::core::{self, Element, Size}; -use crate::lazy::component::{self, Component}; -use crate::lazy::{Lazy, Responsive}; +use crate::lazy::component; use std::hash::Hash; +pub use crate::lazy::{Component, Lazy, Responsive}; + /// Creates a new [`Lazy`] widget with the given data `Dependency` and a /// closure that can turn this data into a widget tree. #[cfg(feature = "lazy")] diff --git a/widget/src/lazy/responsive.rs b/widget/src/lazy/responsive.rs index 2e24f2b30e..dbf281f3dd 100644 --- a/widget/src/lazy/responsive.rs +++ b/widget/src/lazy/responsive.rs @@ -21,6 +21,7 @@ use std::ops::Deref; /// /// A [`Responsive`] widget will always try to fill all the available space of /// its parent. +#[cfg(feature = "lazy")] #[allow(missing_debug_implementations)] pub struct Responsive< 'a, diff --git a/widget/src/lib.rs b/widget/src/lib.rs index 115a29e5cc..a68720d692 100644 --- a/widget/src/lib.rs +++ b/widget/src/lib.rs @@ -42,9 +42,6 @@ pub use helpers::*; #[cfg(feature = "lazy")] mod lazy; -#[cfg(feature = "lazy")] -pub use crate::lazy::{Component, Lazy, Responsive}; - #[cfg(feature = "lazy")] pub use crate::lazy::helpers::*;