diff --git a/crates/composition/src/builder.rs b/crates/composition/src/builder.rs index 8cc4268..dc1c3e7 100644 --- a/crates/composition/src/builder.rs +++ b/crates/composition/src/builder.rs @@ -135,9 +135,10 @@ impl LayerShika { } impl LayerShika { - pub fn with_height(mut self, height: u32) -> Result { - self.config.height = WindowHeight::new(height)?; - Ok(self) + #[must_use] + pub fn with_height(mut self, height: u32) -> Self { + self.config.height = WindowHeight::new(height); + self } #[must_use] diff --git a/crates/domain/src/value_objects/dimensions.rs b/crates/domain/src/value_objects/dimensions.rs index 65efefa..ec881f5 100644 --- a/crates/domain/src/value_objects/dimensions.rs +++ b/crates/domain/src/value_objects/dimensions.rs @@ -1,17 +1,14 @@ -use crate::errors::{DomainError, Result}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct WindowHeight(u32); impl WindowHeight { - pub fn new(height: u32) -> Result { + pub fn new(height: u32) -> Self { if height == 0 { - return Err(DomainError::InvalidDimensions { - width: 0, - height: 0, - }); + Self::default() + } else { + Self(height) } - Ok(Self(height)) } pub const fn from_raw(height: u32) -> Self { @@ -29,10 +26,8 @@ impl Default for WindowHeight { } } -impl TryFrom for WindowHeight { - type Error = DomainError; - - fn try_from(height: u32) -> Result { +impl From for WindowHeight { + fn from(height: u32) -> Self { Self::new(height) } } diff --git a/src/lib.rs b/src/lib.rs index ef34718..2ff80f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ //! use layer_shika::prelude::*; //! //! let (window, system) = LayerShika::from_file("ui/main.slint", "AppWindow")? -//! .with_height(42)? +//! .with_height(42) //! .with_anchor(AnchorEdges::top_bar()) //! .with_exclusive_zone(42) //! .build()?;