Skip to content

Commit

Permalink
Use Into<Id> for container::Id arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jan 30, 2025
1 parent aa0f0e7 commit ea8696e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions widget/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ea8696e

Please sign in to comment.