From 16503785671e450e8ee23ed30a78e8b59582edb9 Mon Sep 17 00:00:00 2001 From: pml68 Date: Sat, 14 Dec 2024 12:54:21 +0100 Subject: feat: switch to `blob_uuid` for uuid generation --- iced_builder/src/types/rendered_element.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'iced_builder/src/types') diff --git a/iced_builder/src/types/rendered_element.rs b/iced_builder/src/types/rendered_element.rs index dd7e1b2..3bb3626 100755 --- a/iced_builder/src/types/rendered_element.rs +++ b/iced_builder/src/types/rendered_element.rs @@ -1,7 +1,7 @@ +use blob_uuid::random_blob; use iced::advanced::widget::Id; use iced::{widget, Element, Length}; use serde::{Deserialize, Serialize}; -use unique_id::{string::StringGenerator, Generator}; use crate::{types::Message, Result}; use std::collections::BTreeMap; @@ -18,9 +18,8 @@ pub struct RenderedElement { impl RenderedElement { fn new(name: ElementName) -> Self { - let gen = StringGenerator::default(); Self { - id: gen.next_id(), + id: random_blob(), child_elements: None, name, options: BTreeMap::new(), @@ -28,9 +27,8 @@ impl RenderedElement { } fn with(name: ElementName, child_elements: Vec) -> Self { - let gen = StringGenerator::default(); Self { - id: gen.next_id(), + id: random_blob(), child_elements: Some(child_elements), name, options: BTreeMap::new(), @@ -95,7 +93,7 @@ impl RenderedElement { pub fn remove(&mut self, element: &RenderedElement) { if let Some(child_elements) = self.child_elements.as_mut() { if let Some(index) = child_elements.iter().position(|x| x == element) { - child_elements.remove(index); + let _ = child_elements.remove(index); } } } @@ -157,16 +155,17 @@ impl RenderedElement { fn preset_options(mut self, options: Vec<&str>) -> Self { for opt in options { - self.options.insert(opt.to_owned(), None); + let _ = self.options.insert(opt.to_owned(), None); } self } - pub fn option<'a>(&mut self, option: &'a str, value: &'a str) -> Self { - self.options + pub fn option<'a>(mut self, option: &'a str, value: &'a str) -> Self { + let _ = self + .options .entry(option.to_owned()) .and_modify(|opt| *opt = Some(value.to_owned())); - self.clone() + self } pub fn as_element<'a>(self) -> Element<'a, Message> { -- cgit v1.2.3