FlexibleDimension now implements Zero

This commit is contained in:
Jonathan Johnson 2024-01-08 09:06:49 -08:00
parent adb51dba7e
commit 5556d2ea6d
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
3 changed files with 13 additions and 4 deletions

View file

@ -45,6 +45,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Dynamic<Children>::wrap` has been renamed to `into_wrap` for consistency.
- Cushy now has its own `KeyEvent` type, as winit's has private fields. This
prevented simulating input in a `VirtualWindow`.
- `FlexibleDimension::ZERO` has been removed, and now `FlexibleDimension`
implements `Zero` which defines an associated constant of the same name and
purpose.
### Fixed

View file

@ -649,9 +649,15 @@ pub enum FlexibleDimension {
Dimension(Dimension),
}
impl FlexibleDimension {
/// A dimension of 0 pixels.
pub const ZERO: Self = Self::Dimension(Dimension::ZERO);
impl Zero for FlexibleDimension {
const ZERO: Self = Self::Dimension(Dimension::ZERO);
fn is_zero(&self) -> bool {
match self {
FlexibleDimension::Auto => false,
FlexibleDimension::Dimension(dim) => dim.is_zero(),
}
}
}
impl Debug for FlexibleDimension {

View file

@ -1,7 +1,7 @@
use std::fmt::Debug;
use figures::units::UPx;
use figures::{Fraction, IntoSigned, Point, Rect, ScreenScale, Size};
use figures::{Fraction, IntoSigned, Point, Rect, ScreenScale, Size, Zero};
use crate::context::{AsEventContext, EventContext, LayoutContext};
use crate::styles::{Edges, FlexibleDimension};