Skip to content

Commit f1ea049

Browse files
committed
Fix format
1 parent 5406224 commit f1ea049

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

web/src/widget/toggler.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ use dodrio::bumpalo;
77
use std::rc::Rc;
88

99
/// A toggler that can be toggled.
10-
///
10+
///
1111
/// # Example
12-
///
12+
///
1313
/// ```
1414
/// # use iced_web::Toggler;
15-
///
15+
///
1616
/// pub enum Message {
1717
/// TogglerToggled(bool),
1818
/// }
19-
///
19+
///
2020
/// let is_active = true;
21-
///
21+
///
2222
/// Toggler::new(is_active, String::from("Toggle me!"), Message::TogglerToggled);
2323
/// ```
24-
///
24+
///
2525
#[allow(missing_debug_implementations)]
2626
pub struct Toggler<Message> {
2727
is_active: bool,
@@ -34,16 +34,20 @@ pub struct Toggler<Message> {
3434

3535
impl<Message> Toggler<Message> {
3636
/// Creates a new [`Toggler`].
37-
///
37+
///
3838
/// It expects:
3939
/// * a boolean describing whether the [`Toggler`] is active or not
4040
/// * An optional label for the [`Toggler`]
4141
/// * a function that will be called when the [`Toggler`] is toggled. It
4242
/// will receive the new state of the [`Toggler`] and must produce a
4343
/// `Message`.
44-
///
44+
///
4545
/// [`Toggler`]: struct.Toggler.html
46-
pub fn new<F>(is_active: bool, label: impl Into<Option<String>>, f: F) -> Self
46+
pub fn new<F>(
47+
is_active: bool,
48+
label: impl Into<Option<String>>,
49+
f: F,
50+
) -> Self
4751
where
4852
F: 'static + Fn(bool) -> Message,
4953
{
@@ -58,23 +62,23 @@ impl<Message> Toggler<Message> {
5862
}
5963

6064
/// Sets the width of the [`Toggler`].
61-
///
65+
///
6266
/// [`Toggler`]: struct.Toggler.html
6367
pub fn width(mut self, width: Length) -> Self {
6468
self.width = width;
6569
self
6670
}
6771

6872
/// Sets the style of the [`Toggler`].
69-
///
73+
///
7074
/// [`Toggler`]: struct.Toggler.html
7175
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
7276
self.style = style.into();
7377
self
7478
}
7579

7680
/// Sets the id of the [`Toggler`].
77-
///
81+
///
7882
/// [`Toggler`]: struct.Toggler.html
7983
pub fn id(mut self, id: impl Into<String>) -> Self {
8084
self.id = Some(id.into());
@@ -95,9 +99,10 @@ where
9599
use dodrio::builder::*;
96100
use dodrio::bumpalo::collections::String;
97101

98-
let toggler_label = &self.label.as_ref().map(|label| {
99-
String::from_str_in(&label, bump).into_bump_str()
100-
});
102+
let toggler_label = &self
103+
.label
104+
.as_ref()
105+
.map(|label| String::from_str_in(&label, bump).into_bump_str());
101106

102107
let event_bus = bus.clone();
103108
let on_toggle = self.on_toggle.clone();
@@ -125,9 +130,7 @@ where
125130
})
126131
.finish();
127132

128-
let toggler = span(bump)
129-
.children(vec![span(bump).finish()])
130-
.finish();
133+
let toggler = span(bump).children(vec![span(bump).finish()]).finish();
131134

132135
label
133136
.attr(
@@ -140,7 +143,7 @@ where
140143
bumpalo::format!(in bump, "width: {}; align-items: center", css::length(self.width))
141144
.into_bump_str()
142145
)
143-
.children(
146+
.children(
144147
if let Some(label) = toggler_label {
145148
vec![
146149
text(label),
@@ -165,4 +168,4 @@ where
165168
fn from(toggler: Toggler<Message>) -> Element<'a, Message> {
166169
Element::new(toggler)
167170
}
168-
}
171+
}

0 commit comments

Comments
 (0)