diff options
| author | pml68 <contact@pml68.dev> | 2024-12-14 12:54:21 +0100 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2024-12-14 13:52:26 +0100 |
| commit | 16503785671e450e8ee23ed30a78e8b59582edb9 (patch) | |
| tree | c42625b539299d8634eff4a5e886e7fe352223aa /iced_builder | |
| parent | feat: remove `indexmap` in favor of BTreeMap (diff) | |
| download | iced-builder-16503785671e450e8ee23ed30a78e8b59582edb9.tar.gz | |
feat: switch to `blob_uuid` for uuid generation
Diffstat (limited to 'iced_builder')
| -rw-r--r-- | iced_builder/Cargo.toml | 26 | ||||
| -rwxr-xr-x | iced_builder/src/types/rendered_element.rs | 19 |
2 files changed, 34 insertions, 11 deletions
diff --git a/iced_builder/Cargo.toml b/iced_builder/Cargo.toml index 95458bc..41a8b51 100644 --- a/iced_builder/Cargo.toml +++ b/iced_builder/Cargo.toml @@ -18,7 +18,7 @@ serde_json = "1.0.133" tokio = { version = "1.42.0", features = ["fs"] } rfd = { version = "0.15.1", default-features = false, features = ["async-std", "gtk3"] } rust-format = "0.3.4" -unique_id = "0.1.5" +blob-uuid = "0.5.0" thiserror = "2.0.6" [build-dependencies] @@ -31,3 +31,27 @@ windows_exe_info = "0.4" [[bin]] name = "iced-builder" path = "src/main.rs" + +[lints.rust] +missing_debug_implementations = "deny" +# missing_docs = "deny" +unsafe_code = "deny" +unused_results = "deny" + +[lints.clippy] +type-complexity = "allow" +semicolon_if_nothing_returned = "deny" +trivially-copy-pass-by-ref = "deny" +default_trait_access = "deny" +match-wildcard-for-single-variants = "deny" +redundant-closure-for-method-calls = "deny" +filter_map_next = "deny" +manual_let_else = "deny" +unused_async = "deny" +from_over_into = "deny" +needless_borrow = "deny" +new_without_default = "deny" +useless_conversion = "deny" + +[lints.rustdoc] +broken_intra_doc_links = "forbid" 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<RenderedElement>) -> 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> { |
