Make toggle method accept impl Into<Option<bool>> (#3446)

This PR makes the `toggle` method on the various list components accept
an `impl Into<Option<bool>>` instead of just an `Option<bool>`.

This allows a caller with just a `bool` avoid having to wrap the
`Option` themselves.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2023-11-29 16:13:41 -05:00
committed by GitHub
parent fb377aed73
commit df5de47a78
5 changed files with 10 additions and 11 deletions
+3 -4
View File
@@ -34,10 +34,9 @@ impl RenderOnce for Disclosure {
fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
IconButton::new(
"toggle",
if self.is_open {
Icon::ChevronDown
} else {
Icon::ChevronRight
match self.is_open {
true => Icon::ChevronDown,
false => Icon::ChevronRight,
},
)
.color(Color::Muted)
+2 -2
View File
@@ -44,8 +44,8 @@ impl List {
self
}
pub fn toggle(mut self, toggle: Option<bool>) -> Self {
self.toggle = toggle;
pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {
self.toggle = toggle.into();
self
}
}
@@ -36,8 +36,8 @@ impl ListHeader {
}
}
pub fn toggle(mut self, toggle: Option<bool>) -> Self {
self.toggle = toggle;
pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {
self.toggle = toggle.into();
self
}
+2 -2
View File
@@ -70,8 +70,8 @@ impl ListItem {
self
}
pub fn toggle(mut self, toggle: Option<bool>) -> Self {
self.toggle = toggle;
pub fn toggle(mut self, toggle: impl Into<Option<bool>>) -> Self {
self.toggle = toggle.into();
self
}