diff options
| author | Kirill Chibisov <contact@kchibisov.com> | 2025-05-26 21:08:44 +0900 |
|---|---|---|
| committer | Kirill Chibisov <contact@kchibisov.com> | 2025-05-28 14:16:36 +0900 |
| commit | ee48fad2cff393053cb0f4d4c890d8da616f317f (patch) | |
| tree | ccac1e5f48b948b40381be955c4d2f0b466c9d93 | |
| parent | 1fb1fd225e318b0bd1a1ccdad07f36386e0024ec (diff) | |
| download | r-alacritty-ee48fad2cff393053cb0f4d4c890d8da616f317f.tar.gz r-alacritty-ee48fad2cff393053cb0f4d4c890d8da616f317f.tar.bz2 r-alacritty-ee48fad2cff393053cb0f4d4c890d8da616f317f.zip | |
Fix clippy warnings
| -rw-r--r-- | alacritty/src/config/monitor.rs | 2 | ||||
| -rw-r--r-- | alacritty/src/display/content.rs | 6 | ||||
| -rw-r--r-- | alacritty/src/display/hint.rs | 6 | ||||
| -rw-r--r-- | alacritty/src/display/mod.rs | 4 | ||||
| -rw-r--r-- | alacritty/src/event.rs | 6 | ||||
| -rw-r--r-- | alacritty/src/input/mod.rs | 2 | ||||
| -rw-r--r-- | alacritty/src/ipc.rs | 2 | ||||
| -rw-r--r-- | alacritty/src/renderer/text/builtin_font.rs | 2 | ||||
| -rw-r--r-- | alacritty_config_derive/src/config_deserialize/de_struct.rs | 2 | ||||
| -rw-r--r-- | alacritty_terminal/src/event_loop.rs | 2 | ||||
| -rw-r--r-- | alacritty_terminal/src/tty/unix.rs | 6 |
11 files changed, 20 insertions, 20 deletions
diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs index 3f73f120..48271baf 100644 --- a/alacritty/src/config/monitor.rs +++ b/alacritty/src/config/monitor.rs @@ -42,7 +42,7 @@ impl ConfigMonitor { // a regular file. paths.retain(|path| { // Call `metadata` to resolve symbolic links. - path.metadata().map_or(false, |metadata| metadata.file_type().is_file()) + path.metadata().is_ok_and(|metadata| metadata.file_type().is_file()) }); // Canonicalize paths, keeping the base paths for symlinks. diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs index edd2709f..dfad5712 100644 --- a/alacritty/src/display/content.rs +++ b/alacritty/src/display/content.rs @@ -218,7 +218,7 @@ impl RenderableCell { Self::compute_bg_alpha(content.config, cell.bg) }; - let is_selected = content.terminal_content.selection.map_or(false, |selection| { + let is_selected = content.terminal_content.selection.is_some_and(|selection| { selection.contains_cell( &cell, content.terminal_content.cursor.point, @@ -262,8 +262,8 @@ impl RenderableCell { bg = content.color(NamedColor::Foreground as usize); bg_alpha = 1.0; } - } else if content.search.as_mut().map_or(false, |search| search.advance(cell.point)) { - let focused = content.focused_match.map_or(false, |fm| fm.contains(&cell.point)); + } else if content.search.as_mut().is_some_and(|search| search.advance(cell.point)) { + let focused = content.focused_match.is_some_and(|fm| fm.contains(&cell.point)); let (config_fg, config_bg) = if focused { (colors.search.focused_match.foreground, colors.search.focused_match.background) } else { diff --git a/alacritty/src/display/hint.rs b/alacritty/src/display/hint.rs index 3f10b4e5..38c9da1c 100644 --- a/alacritty/src/display/hint.rs +++ b/alacritty/src/display/hint.rs @@ -396,7 +396,7 @@ pub fn highlighted_at<T>( config.hints.enabled.iter().find_map(|hint| { // Check if all required modifiers are pressed. - let highlight = hint.mouse.map_or(false, |mouse| { + let highlight = hint.mouse.is_some_and(|mouse| { mouse.enabled && mouse_mods.contains(mouse.mods.0) && (!mouse_mode || mouse_mods.contains(ModifiersState::SHIFT)) @@ -432,7 +432,7 @@ fn hyperlink_at<T>(term: &Term<T>, point: Point) -> Option<(Hyperlink, Match)> { let mut match_end = point; for cell in grid.iter_from(point) { - if cell.hyperlink().map_or(false, |link| link == hyperlink) { + if cell.hyperlink().is_some_and(|link| link == hyperlink) { match_end = cell.point; } else { break; @@ -442,7 +442,7 @@ fn hyperlink_at<T>(term: &Term<T>, point: Point) -> Option<(Hyperlink, Match)> { let mut match_start = point; let mut iter = grid.iter_from(point); while let Some(cell) = iter.prev() { - if cell.hyperlink().map_or(false, |link| link == hyperlink) { + if cell.hyperlink().is_some_and(|link| link == hyperlink) { match_start = cell.point; } else { break; diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs index 6a84bf0f..8f875df2 100644 --- a/alacritty/src/display/mod.rs +++ b/alacritty/src/display/mod.rs @@ -862,7 +862,7 @@ impl Display { let hyperlink = cell.extra.as_ref().and_then(|extra| extra.hyperlink.as_ref()); let should_highlight = |hint: &Option<HintMatch>| { - hint.as_ref().map_or(false, |hint| hint.should_highlight(point, hyperlink)) + hint.as_ref().is_some_and(|hint| hint.should_highlight(point, hyperlink)) }; if should_highlight(highlighted_hint) || should_highlight(vi_highlighted_hint) { damage_tracker.frame().damage_point(cell.point); @@ -1097,7 +1097,7 @@ impl Display { if highlighted_hint.is_some() { // If mouse changed the line, we should update the hyperlink preview, since the // highlighted hint could be disrupted by the old preview. - dirty = self.hint_mouse_point.map_or(false, |p| p.line != point.line); + dirty = self.hint_mouse_point.is_some_and(|p| p.line != point.line); self.hint_mouse_point = Some(point); self.window.set_mouse_cursor(CursorIcon::Pointer); } else if self.highlighted_hint.is_some() { diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index d2fd5c0d..defea8b7 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -681,7 +681,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon let vi_mode = self.terminal.mode().contains(TermMode::VI); // Update selection. - if vi_mode && self.terminal.selection.as_ref().map_or(false, |s| !s.is_empty()) { + if vi_mode && self.terminal.selection.as_ref().is_some_and(|s| !s.is_empty()) { self.update_selection(self.terminal.vi_mode_cursor.point, Side::Right); } else if self.mouse.left_button_state == ElementState::Pressed || self.mouse.right_button_state == ElementState::Pressed @@ -722,7 +722,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon // Clear the selection on the terminal. let selection = self.terminal.selection.take(); // Mark the terminal as dirty when selection wasn't empty. - *self.dirty |= selection.map_or(false, |s| !s.is_empty()); + *self.dirty |= selection.is_some_and(|s| !s.is_empty()); } fn update_selection(&mut self, mut point: Point, side: Side) { @@ -2012,7 +2012,7 @@ impl input::Processor<EventProxy, ActionContext<'_, Notifier, EventProxy>> { | WindowEvent::Moved(_) => (), } }, - WinitEvent::Suspended { .. } + WinitEvent::Suspended | WinitEvent::NewEvents { .. } | WinitEvent::DeviceEvent { .. } | WinitEvent::LoopExiting diff --git a/alacritty/src/input/mod.rs b/alacritty/src/input/mod.rs index a69d2989..a003f534 100644 --- a/alacritty/src/input/mod.rs +++ b/alacritty/src/input/mod.rs @@ -1083,7 +1083,7 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { if let Some(mouse_state) = self.message_bar_cursor_state() { mouse_state - } else if self.ctx.display().highlighted_hint.as_ref().map_or(false, hint_highlighted) { + } else if self.ctx.display().highlighted_hint.as_ref().is_some_and(hint_highlighted) { CursorIcon::Pointer } else if !self.ctx.modifiers().state().shift_key() && self.ctx.mouse_mode() { CursorIcon::Default diff --git a/alacritty/src/ipc.rs b/alacritty/src/ipc.rs index 919035a6..a5f43437 100644 --- a/alacritty/src/ipc.rs +++ b/alacritty/src/ipc.rs @@ -85,7 +85,7 @@ pub fn send_message(socket: Option<PathBuf>, message: SocketMessage) -> IoResult let mut socket = find_socket(socket)?; let message = serde_json::to_string(&message)?; - socket.write_all(message[..].as_bytes())?; + socket.write_all(message.as_bytes())?; let _ = socket.flush(); Ok(()) diff --git a/alacritty/src/renderer/text/builtin_font.rs b/alacritty/src/renderer/text/builtin_font.rs index ece7eb86..3d25ec94 100644 --- a/alacritty/src/renderer/text/builtin_font.rs +++ b/alacritty/src/renderer/text/builtin_font.rs @@ -660,7 +660,7 @@ fn powerline_drawing( }) } -#[repr(packed)] +#[repr(C, packed)] #[derive(Clone, Copy, Debug, Default)] struct Pixel { _r: u8, diff --git a/alacritty_config_derive/src/config_deserialize/de_struct.rs b/alacritty_config_derive/src/config_deserialize/de_struct.rs index ad38863e..ee165c3b 100644 --- a/alacritty_config_derive/src/config_deserialize/de_struct.rs +++ b/alacritty_config_derive/src/config_deserialize/de_struct.rs @@ -174,7 +174,7 @@ fn field_deserializer(field_streams: &mut FieldStreams, field: &Field) -> Result // Create token stream for deserializing "none" string into `Option<T>`. if let Type::Path(type_path) = &field.ty { - if type_path.path.segments.iter().last().map_or(false, |s| s.ident == "Option") { + if type_path.path.segments.iter().next_back().is_some_and(|s| s.ident == "Option") { match_assignment_stream = quote! { if value.as_str().map_or(false, |s| s.eq_ignore_ascii_case("none")) { config.#ident = None; diff --git a/alacritty_terminal/src/event_loop.rs b/alacritty_terminal/src/event_loop.rs index 1bef1d4f..285c08e2 100644 --- a/alacritty_terminal/src/event_loop.rs +++ b/alacritty_terminal/src/event_loop.rs @@ -338,7 +338,7 @@ impl event::Notify for Notifier { { let bytes = bytes.into(); // Terminal hangs if we send 0 bytes through. - if bytes.len() == 0 { + if bytes.is_empty() { return; } diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index 884cb5c1..bbddfca6 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -82,11 +82,11 @@ fn get_pw_entry(buf: &mut [i8; 1024]) -> Result<Passwd<'_>> { let entry = unsafe { entry.assume_init() }; if status < 0 { - return Err(Error::new(ErrorKind::Other, "getpwuid_r failed")); + return Err(Error::other("getpwuid_r failed")); } if res.is_null() { - return Err(Error::new(ErrorKind::Other, "pw not found")); + return Err(Error::other("pw not found")); } // Sanity check. @@ -247,7 +247,7 @@ pub fn from_fd(config: &Options, window_id: u64, master: OwnedFd, slave: OwnedFd // Create a new process group. let err = libc::setsid(); if err == -1 { - return Err(Error::new(ErrorKind::Other, "Failed to set session id")); + return Err(Error::other("Failed to set session id")); } // Set working directory, ignoring invalid paths. |