Merge pull request #2090 from nyurik/mapping

Chore: Apply clippy map transformations
This commit is contained in:
Héctor Ramón 2023-09-19 13:22:21 +02:00 committed by GitHub
commit 582da10ae2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 15 deletions

View file

@ -69,8 +69,6 @@ impl Click {
};
self.position == new_position
&& duration
.map(|duration| duration.as_millis() <= 300)
.unwrap_or(false)
&& duration.is_some_and(|duration| duration.as_millis() <= 300)
}
}

View file

@ -200,8 +200,10 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
viewport.scale_factor(),
)
})
.map(mouse::Cursor::Available)
.unwrap_or(mouse::Cursor::Unavailable),
.map_or(
mouse::Cursor::Unavailable,
mouse::Cursor::Available,
),
&mut renderer,
&Theme::Dark,
&renderer::Style {

View file

@ -293,10 +293,7 @@ fn numeric_input(
) -> Element<'_, Option<u32>> {
text_input(
placeholder,
&value
.as_ref()
.map(ToString::to_string)
.unwrap_or_else(String::new),
&value.as_ref().map_or_else(String::new, ToString::to_string),
)
.on_input(move |text| {
if text.is_empty() {

View file

@ -56,7 +56,7 @@ impl Cache {
.ok()
});
tree.map(Svg::Loaded).unwrap_or(Svg::NotFound)
tree.map_or(Svg::NotFound, Svg::Loaded)
}
svg::Data::Bytes(bytes) => {
match usvg::Tree::from_data(bytes, &usvg::Options::default()) {

View file

@ -349,7 +349,7 @@ fn multisample_state(
antialiasing: Option<Antialiasing>,
) -> wgpu::MultisampleState {
wgpu::MultisampleState {
count: antialiasing.map(|a| a.sample_count()).unwrap_or(1),
count: antialiasing.map_or(1, Antialiasing::sample_count),
mask: !0,
alpha_to_coverage_enabled: false,
}

View file

@ -97,8 +97,7 @@ where
self.viewport.scale_factor(),
)
})
.map(mouse::Cursor::Available)
.unwrap_or(mouse::Cursor::Unavailable)
.map_or(mouse::Cursor::Unavailable, mouse::Cursor::Available)
}
/// Returns the current keyboard modifiers of the [`State`].

View file

@ -17,8 +17,7 @@ impl Clipboard {
pub fn connect(window: &winit::window::Window) -> Clipboard {
let state = window_clipboard::Clipboard::connect(window)
.ok()
.map(State::Connected)
.unwrap_or(State::Unavailable);
.map_or(State::Unavailable, State::Connected);
Clipboard { state }
}