diff --git a/examples/download_progress/src/main.rs b/examples/download_progress/src/main.rs index 0ba8a297..30559401 100644 --- a/examples/download_progress/src/main.rs +++ b/examples/download_progress/src/main.rs @@ -117,9 +117,7 @@ impl Download { pub fn start(&mut self) -> Task { match self.state { - State::Idle { .. } - | State::Finished { .. } - | State::Errored { .. } => { + State::Idle | State::Finished | State::Errored => { let (task, handle) = Task::sip( download( "https://huggingface.co/\ @@ -161,10 +159,10 @@ impl Download { pub fn view(&self) -> Element { let current_progress = match &self.state { - State::Idle { .. } => 0.0, + State::Idle => 0.0, State::Downloading { progress, .. } => *progress, - State::Finished { .. } => 100.0, - State::Errored { .. } => 0.0, + State::Finished => 100.0, + State::Errored => 0.0, }; let progress_bar = progress_bar(0.0..=100.0, current_progress); diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs index 2e972f6b..d8ccd27c 100644 --- a/examples/pokedex/src/main.rs +++ b/examples/pokedex/src/main.rs @@ -33,7 +33,7 @@ impl Pokedex { let subtitle = match self { Pokedex::Loading => "Loading", Pokedex::Loaded { pokemon, .. } => &pokemon.name, - Pokedex::Errored { .. } => "Whoops!", + Pokedex::Errored => "Whoops!", }; format!("{subtitle} - Pokédex") diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs index dc314df8..b5d6d523 100644 --- a/examples/toast/src/main.rs +++ b/examples/toast/src/main.rs @@ -327,9 +327,10 @@ mod toast { instants.truncate(new); } (old, new) if old < new => { - instants.extend( - std::iter::repeat(Some(Instant::now())).take(new - old), - ); + instants.extend(std::iter::repeat_n( + Some(Instant::now()), + new - old, + )); } _ => {} } diff --git a/wgpu/src/buffer.rs b/wgpu/src/buffer.rs index 463ea24a..99092fc2 100644 --- a/wgpu/src/buffer.rs +++ b/wgpu/src/buffer.rs @@ -4,9 +4,8 @@ use std::ops::RangeBounds; pub const MAX_WRITE_SIZE: usize = 100 * 1024; -#[allow(unsafe_code)] -const MAX_WRITE_SIZE_U64: NonZeroU64 = - unsafe { NonZeroU64::new_unchecked(MAX_WRITE_SIZE as u64) }; +const MAX_WRITE_SIZE_U64: NonZeroU64 = NonZeroU64::new(MAX_WRITE_SIZE as u64) + .expect("MAX_WRITE_SIZE must be non-zero"); #[derive(Debug)] pub struct Buffer { diff --git a/widget/src/text_input/value.rs b/widget/src/text_input/value.rs index 46a1f754..7456ce63 100644 --- a/widget/src/text_input/value.rs +++ b/widget/src/text_input/value.rs @@ -120,9 +120,11 @@ impl Value { /// dot ('•') character. pub fn secure(&self) -> Self { Self { - graphemes: std::iter::repeat(String::from("•")) - .take(self.graphemes.len()) - .collect(), + graphemes: std::iter::repeat_n( + String::from("•"), + self.graphemes.len(), + ) + .collect(), } } } diff --git a/widget/src/tooltip.rs b/widget/src/tooltip.rs index 2d674bca..ce34f2a5 100644 --- a/widget/src/tooltip.rs +++ b/widget/src/tooltip.rs @@ -386,9 +386,11 @@ where renderer, &layout::Limits::new( Size::ZERO, - self.snap_within_viewport - .then(|| viewport.size()) - .unwrap_or(Size::INFINITY), + if self.snap_within_viewport { + viewport.size() + } else { + Size::INFINITY + }, ) .shrink(Padding::new(self.padding)), );