diff --git a/Cargo.toml b/Cargo.toml index 45cb43d5..cbe64aca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "libcosmic" version = "0.1.0" edition = "2021" +rust-version = "1.71" [lib] name = "cosmic" diff --git a/src/widget/segmented_button/horizontal.rs b/src/widget/segmented_button/horizontal.rs index 9ba58022..5fb02916 100644 --- a/src/widget/segmented_button/horizontal.rs +++ b/src/widget/segmented_button/horizontal.rs @@ -45,11 +45,11 @@ where } #[allow(clippy::cast_precision_loss)] - fn variant_button_bounds( - &self, - state: &LocalState, + fn variant_button_bounds<'b>( + &'b self, + state: &'b LocalState, mut bounds: Rectangle, - ) -> impl Iterator { + ) -> Box + 'b> { let num = state.buttons_visible; let spacing = f32::from(self.spacing); let mut homogenous_width = 0.0; @@ -66,25 +66,27 @@ where / num as f32; } - self.model - .order - .iter() - .copied() - .enumerate() - .skip(state.buttons_offset) - .take(state.buttons_visible) - .map(move |(nth, key)| { - let mut this_bounds = bounds; + Box::new( + self.model + .order + .iter() + .copied() + .enumerate() + .skip(state.buttons_offset) + .take(state.buttons_visible) + .map(move |(nth, key)| { + let mut this_bounds = bounds; - if !state.collapsed && Length::Shrink == self.width { - this_bounds.width = state.internal_layout[nth].width; - } else { - this_bounds.width = homogenous_width; - } + if !state.collapsed && Length::Shrink == self.width { + this_bounds.width = state.internal_layout[nth].width; + } else { + this_bounds.width = homogenous_width; + } - bounds.x += this_bounds.width + spacing; - (key, this_bounds) - }) + bounds.x += this_bounds.width + spacing; + (key, this_bounds) + }), + ) } #[allow(clippy::cast_precision_loss)] diff --git a/src/widget/segmented_button/vertical.rs b/src/widget/segmented_button/vertical.rs index 5c541a85..c9fc5833 100644 --- a/src/widget/segmented_button/vertical.rs +++ b/src/widget/segmented_button/vertical.rs @@ -45,24 +45,26 @@ where } #[allow(clippy::cast_precision_loss)] - fn variant_button_bounds( - &self, - state: &LocalState, + fn variant_button_bounds<'b>( + &'b self, + state: &'b LocalState, mut bounds: Rectangle, - ) -> impl Iterator { + ) -> Box + 'b> { let spacing = f32::from(self.spacing); - self.model - .order - .iter() - .copied() - .enumerate() - .map(move |(_nth, key)| { - let mut this_bounds = bounds; - this_bounds.height = state.internal_layout[0].height; - bounds.y += this_bounds.height + spacing; - (key, this_bounds) - }) + Box::new( + self.model + .order + .iter() + .copied() + .enumerate() + .map(move |(_nth, key)| { + let mut this_bounds = bounds; + this_bounds.height = state.internal_layout[0].height; + bounds.y += this_bounds.height + spacing; + (key, this_bounds) + }), + ) } #[allow(clippy::cast_precision_loss)] diff --git a/src/widget/segmented_button/widget.rs b/src/widget/segmented_button/widget.rs index a223525a..f2d58d88 100644 --- a/src/widget/segmented_button/widget.rs +++ b/src/widget/segmented_button/widget.rs @@ -33,11 +33,11 @@ pub trait SegmentedVariant { ) -> super::Appearance; /// Calculates the bounds for visible buttons. - fn variant_button_bounds( - &self, - state: &LocalState, + fn variant_button_bounds<'b>( + &'b self, + state: &'b LocalState, bounds: Rectangle, - ) -> impl Iterator; + ) -> Box + 'b>; /// Calculates the layout of this variant. fn variant_layout(