diff options
author | 2025-01-30 02:47:14 +0100 | |
---|---|---|
committer | 2025-01-30 02:47:14 +0100 | |
commit | ea8696eac2049fc19ea6ce5849922a002123ac37 (patch) | |
tree | 9ed0db5ac2ba1cd68908bfe29aa8984b0cc9ed46 /widget | |
parent | aa0f0e73aa06242b8228fd81df8acaac6f377b71 (diff) | |
download | iced-ea8696eac2049fc19ea6ce5849922a002123ac37.tar.gz iced-ea8696eac2049fc19ea6ce5849922a002123ac37.tar.bz2 iced-ea8696eac2049fc19ea6ce5849922a002123ac37.zip |
Use `Into<Id>` for `container::Id` arguments
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/container.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/widget/src/container.rs b/widget/src/container.rs index a411a7d2..852481f1 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -107,8 +107,8 @@ where } /// Sets the [`Id`] of the [`Container`]. - pub fn id(mut self, id: Id) -> Self { - self.id = Some(id); + pub fn id(mut self, id: impl Into<Id>) -> Self { + self.id = Some(id.into()); self } @@ -480,9 +480,17 @@ impl From<Id> for widget::Id { } } +impl From<&'static str> for Id { + fn from(value: &'static str) -> Self { + Id::new(value) + } +} + /// Produces a [`Task`] that queries the visible screen bounds of the /// [`Container`] with the given [`Id`]. -pub fn visible_bounds(id: Id) -> Task<Option<Rectangle>> { +pub fn visible_bounds(id: impl Into<Id>) -> Task<Option<Rectangle>> { + let id = id.into(); + struct VisibleBounds { target: widget::Id, depth: usize, |