diff options
| author | pml68 <contact@pml68.dev> | 2025-07-01 22:54:31 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-07-01 22:55:16 +0200 |
| commit | 1e6963304f1efdbc15b880a650346c631d15e99b (patch) | |
| tree | fbf2a83fb8e5e9e53343dc745809aae08e8c76f0 /src/types | |
| parent | chore(PKGBUILD): remove clang and mold from `makedepends` [skip ci] (diff) | |
| download | iced-builder-1e6963304f1efdbc15b880a650346c631d15e99b.tar.gz | |
fix: relative project path written to config, bump MSRV to 1.88.0
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/element_name.rs | 4 | ||||
| -rw-r--r-- | src/types/project.rs | 7 | ||||
| -rwxr-xr-x | src/types/rendered_element.rs | 42 |
3 files changed, 25 insertions, 28 deletions
diff --git a/src/types/element_name.rs b/src/types/element_name.rs index 186285d..c824fc5 100644 --- a/src/types/element_name.rs +++ b/src/types/element_name.rs @@ -38,8 +38,8 @@ impl ElementName { Self::Svg(_) => svg(""), Self::Image(_) => image(""), Self::Container => container(None), - Self::Row => row(None), - Self::Column => column(None), + Self::Row => row(vec![]), + Self::Column => column(vec![]), }; match action { Action::Stop | Action::Drop => Ok(None), diff --git a/src/types/project.rs b/src/types/project.rs index 9f78445..5bd986f 100644 --- a/src/types/project.rs +++ b/src/types/project.rs @@ -66,9 +66,10 @@ impl Project { use tokio::fs; let path = if let Some(p) = path { - let parent = p.parent(); - if parent.is_some_and(|parent| !parent.exists()) { - fs::create_dir_all(parent.unwrap()).await?; + if let Some(parent) = p.parent() + && !parent.exists() + { + fs::create_dir_all(parent).await?; } p diff --git a/src/types/rendered_element.rs b/src/types/rendered_element.rs index b7fd839..be2a004 100755 --- a/src/types/rendered_element.rs +++ b/src/types/rendered_element.rs @@ -95,12 +95,11 @@ impl RenderedElement { let Some(parent) = self.find_parent(element) else { return; }; - if let Some(child_elements) = parent.child_elements.as_mut() { - if let Some(index) = + if let Some(child_elements) = parent.child_elements.as_mut() + && let Some(index) = child_elements.iter().position(|x| x == element) - { - let _ = child_elements.remove(index); - } + { + let _ = child_elements.remove(index); } } @@ -525,25 +524,22 @@ pub fn container(content: Option<RenderedElement>) -> RenderedElement { ]) } -pub fn row(child_elements: Option<Vec<RenderedElement>>) -> RenderedElement { - RenderedElement::with(ElementName::Row, child_elements.unwrap_or_default()) - .preset_options(&[ - "spacing", "padding", "width", "height", "align_y", "clip", - ]) +pub fn row(child_elements: Vec<RenderedElement>) -> RenderedElement { + RenderedElement::with(ElementName::Row, child_elements).preset_options(&[ + "spacing", "padding", "width", "height", "align_y", "clip", + ]) } -pub fn column(child_elements: Option<Vec<RenderedElement>>) -> RenderedElement { - RenderedElement::with( - ElementName::Column, - child_elements.unwrap_or_default(), +pub fn column(child_elements: Vec<RenderedElement>) -> RenderedElement { + RenderedElement::with(ElementName::Column, child_elements).preset_options( + &[ + "spacing", + "padding", + "width", + "height", + "max_width", + "align_x", + "clip", + ], ) - .preset_options(&[ - "spacing", - "padding", - "width", - "height", - "max_width", - "align_x", - "clip", - ]) } |
