diff --git a/bidi/src/lib.rs b/bidi/src/lib.rs index 384084667..00b8bead7 100644 --- a/bidi/src/lib.rs +++ b/bidi/src/lib.rs @@ -24,7 +24,7 @@ pub use direction::Direction; pub use level::Level; /// Placeholder codepoint index that corresponds to NO_LEVEL -const DELETED: usize = usize::max_value(); +const DELETED: usize = usize::MAX; #[derive(Debug, Clone, Copy, PartialEq, Eq, FromDynamic, ToDynamic)] pub enum ParagraphDirectionHint { diff --git a/lua-api-crates/mux/src/pane.rs b/lua-api-crates/mux/src/pane.rs index e191c3f13..08357bc41 100644 --- a/lua-api-crates/mux/src/pane.rs +++ b/lua-api-crates/mux/src/pane.rs @@ -42,10 +42,10 @@ impl MuxPane { 0..zone.end_x.saturating_add(1) } else if row == zone.start_y { // first line of multi-line - zone.start_x..usize::max_value() + zone.start_x..usize::MAX } else { // some "middle" line of multi-line - 0..usize::max_value() + 0..usize::MAX } } diff --git a/termwiz/src/widgets/mod.rs b/termwiz/src/widgets/mod.rs index 0a077f9a7..d5b805afc 100644 --- a/termwiz/src/widgets/mod.rs +++ b/termwiz/src/widgets/mod.rs @@ -372,7 +372,7 @@ impl<'widget> Ui<'widget> { abs_coords.x + render_data.coordinates.x, abs_coords.y + render_data.coordinates.y, ); - surface.flush_changes_older_than(SequenceNo::max_value()); + surface.flush_changes_older_than(SequenceNo::MAX); render_data.coordinates }; diff --git a/wezterm-escape-parser/src/csi.rs b/wezterm-escape-parser/src/csi.rs index 7daa46ffc..b6d5ff315 100644 --- a/wezterm-escape-parser/src/csi.rs +++ b/wezterm-escape-parser/src/csi.rs @@ -1311,14 +1311,14 @@ impl Display for Cursor { Cursor::LinePositionBackward(n) => n.write_csi(f, "k")?, Cursor::LinePositionForward(n) => n.write_csi(f, "e")?, Cursor::SetTopAndBottomMargins { top, bottom } => { - if top.as_one_based() == 1 && bottom.as_one_based() == u32::max_value() { + if top.as_one_based() == 1 && bottom.as_one_based() == u32::MAX { write!(f, "r")?; } else { write!(f, "{};{}r", top, bottom)?; } } Cursor::SetLeftAndRightMargins { left, right } => { - if left.as_one_based() == 1 && right.as_one_based() == u32::max_value() { + if left.as_one_based() == 1 && right.as_one_based() == u32::MAX { write!(f, "s")?; } else { write!(f, "{};{}s", left, right)?; @@ -1733,7 +1733,7 @@ fn to_u8(v: &CsiParam) -> Result { match v { CsiParam::P(_) => Err(()), CsiParam::Integer(v) => { - if *v <= i64::from(u8::max_value()) { + if *v <= i64::from(u8::MAX) { Ok(*v as u8) } else { Err(()) @@ -1756,7 +1756,7 @@ fn to_u8(v: &CsiParam) -> Result { fn to_1b_u32(v: &CsiParam) -> Result { match v { CsiParam::Integer(v) if *v == 0 => Ok(1), - CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::max_value()) => Ok(*v as u32), + CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::MAX) => Ok(*v as u32), _ => Err(()), } } @@ -2101,14 +2101,14 @@ impl<'a> CSIParser<'a> { match params { [] => Ok(CSI::Cursor(Cursor::SetTopAndBottomMargins { top: OneBased::new(1), - bottom: OneBased::new(u32::max_value()), + bottom: OneBased::new(u32::MAX), })), [p] => Ok(self.advance_by( 1, params, CSI::Cursor(Cursor::SetTopAndBottomMargins { top: OneBased::from_esc_param(p)?, - bottom: OneBased::new(u32::max_value()), + bottom: OneBased::new(u32::MAX), }), )), [a, CsiParam::P(b';'), b] => Ok(self.advance_by( @@ -2188,7 +2188,7 @@ impl<'a> CSIParser<'a> { params, CSI::Cursor(Cursor::SetLeftAndRightMargins { left: OneBased::from_esc_param(p)?, - right: OneBased::new(u32::max_value()), + right: OneBased::new(u32::MAX), }), )), [a, CsiParam::P(b';'), b] => Ok(self.advance_by( diff --git a/wezterm-escape-parser/src/esc.rs b/wezterm-escape-parser/src/esc.rs index 66ee5b13a..7c449073f 100644 --- a/wezterm-escape-parser/src/esc.rs +++ b/wezterm-escape-parser/src/esc.rs @@ -142,7 +142,7 @@ impl Display for Esc { let packed = code .to_u16() .expect("num-derive failed to implement ToPrimitive"); - if packed > u16::from(u8::max_value()) { + if packed > u16::from(u8::MAX) { write!( f, "{}{}", diff --git a/wezterm-escape-parser/src/lib.rs b/wezterm-escape-parser/src/lib.rs index c9ea144c0..bcd08f279 100644 --- a/wezterm-escape-parser/src/lib.rs +++ b/wezterm-escape-parser/src/lib.rs @@ -573,7 +573,7 @@ impl OneBased { CsiParam::Integer(v) if *v == 0 => Ok(Self { value: num_traits::one(), }), - CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::max_value()) => { + CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::MAX) => { Ok(Self { value: *v as u32 }) } _ => Err(()), @@ -584,10 +584,8 @@ impl OneBased { /// 0 is equivalent to max_value. pub fn from_esc_param_with_big_default(v: &CsiParam) -> core::result::Result { match v { - CsiParam::Integer(v) if *v == 0 => Ok(Self { - value: u32::max_value(), - }), - CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::max_value()) => { + CsiParam::Integer(v) if *v == 0 => Ok(Self { value: u32::MAX }), + CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::MAX) => { Ok(Self { value: *v as u32 }) } _ => Err(()), diff --git a/wezterm-gui/src/overlay/copy.rs b/wezterm-gui/src/overlay/copy.rs index 327cb4baf..7bf7e1c80 100644 --- a/wezterm-gui/src/overlay/copy.rs +++ b/wezterm-gui/src/overlay/copy.rs @@ -466,19 +466,11 @@ impl CopyRenderable { let cursor_is_above_start = self.cursor.y < sel_start.y; let start = SelectionCoordinate::x_y( - if cursor_is_above_start { - usize::max_value() - } else { - 0 - }, + if cursor_is_above_start { usize::MAX } else { 0 }, sel_start.y, ); let end = SelectionCoordinate::x_y( - if cursor_is_above_start { - 0 - } else { - usize::max_value() - }, + if cursor_is_above_start { 0 } else { usize::MAX }, self.cursor.y, ); (start, end) @@ -759,7 +751,7 @@ impl CopyRenderable { fn move_to_bottom(&mut self) { // This will get fixed up by clamp_cursor_to_scrollback - self.cursor.y = isize::max_value(); + self.cursor.y = isize::MAX; self.select_to_cursor_pos(); } @@ -826,7 +818,7 @@ impl CopyRenderable { fn move_backward_one_word(&mut self) { let y = if self.cursor.x == 0 && self.cursor.y > 0 { - self.cursor.x = usize::max_value(); + self.cursor.x = usize::MAX; self.cursor.y.saturating_sub(1) } else { self.cursor.y @@ -835,7 +827,7 @@ impl CopyRenderable { let (top, lines) = self.delegate.get_lines(y..y + 1); if let Some(line) = lines.get(0) { self.cursor.y = top; - if self.cursor.x == usize::max_value() { + if self.cursor.x == usize::MAX { self.cursor.x = line.len().saturating_sub(1); } let s = line.columns_as_str(0..self.cursor.x.saturating_add(1)); @@ -871,7 +863,7 @@ impl CopyRenderable { if last_was_whitespace && self.cursor.y > 0 { // The line begins with whitespace - self.cursor.x = usize::max_value(); + self.cursor.x = usize::MAX; self.cursor.y -= 1; return self.move_backward_one_word(); } diff --git a/wezterm-gui/src/selection.rs b/wezterm-gui/src/selection.rs index c822482a9..96d748c7b 100644 --- a/wezterm-gui/src/selection.rs +++ b/wezterm-gui/src/selection.rs @@ -187,7 +187,7 @@ impl SelectionRange { return Self { start: SelectionCoordinate::x_y(0, logical.first_row), end: SelectionCoordinate::x_y( - usize::max_value(), + usize::MAX, logical.first_row + (logical.physical_lines.len() - 1) as StableRowIndex, ), }; @@ -315,7 +315,7 @@ impl SelectionRange { } /// Yields a range representing the selected columns for the specified row. - /// Not that the range may include usize::max_value() for some rows; this + /// Note that the range may include `usize::MAX` for some rows; this /// indicates that the selection extends to the end of that row. /// Since this struct has no knowledge of line length, it cannot be /// more precise than that. @@ -348,10 +348,10 @@ impl SelectionRange { SelectionX::Cell(0).range(norm.end.x.saturating_add(1)) } else if row == norm.start.y { // first line of multi-line - norm.start.x.range(SelectionX::Cell(usize::max_value())) + norm.start.x.range(SelectionX::Cell(usize::MAX)) } else { // some "middle" line of multi-line - 0..usize::max_value() + 0..usize::MAX } } } diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index b3393a62c..2fc9bf9a3 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -494,7 +494,7 @@ impl TabBarState { title_width.saturating_sub(number_of_tabs.saturating_sub(1) + new_tab.len()); let tab_width_max = if config.use_fancy_tab_bar || available_cells >= titles_len { // We can render each title with its full width - usize::max_value() + usize::MAX } else { // We need to clamp the length to balance them out available_cells / number_of_tabs diff --git a/wezterm-gui/src/termwindow/charselect.rs b/wezterm-gui/src/termwindow/charselect.rs index 9e1beb46a..5bcda4b67 100644 --- a/wezterm-gui/src/termwindow/charselect.rs +++ b/wezterm-gui/src/termwindow/charselect.rs @@ -254,7 +254,7 @@ impl MatchResult { // Pump up the score for an exact match, otherwise // the order may be undesirable if there are a lot // of candidates with the same score - u32::max_value() + u32::MAX } else { score }, @@ -302,7 +302,7 @@ fn compute_matches(selection: &str, aliases: &[Alias], group: CharSelectGroup) - glyph, MatchResult { row_idx, - score: u32::max_value(), + score: u32::MAX, }, )) } else { diff --git a/wezterm-gui/src/termwindow/palette.rs b/wezterm-gui/src/termwindow/palette.rs index 7b0a5ffec..5f99ae2dd 100644 --- a/wezterm-gui/src/termwindow/palette.rs +++ b/wezterm-gui/src/termwindow/palette.rs @@ -183,7 +183,7 @@ impl MatchResult { // Pump up the score for an exact match, otherwise // the order may be undesirable if there are a lot // of candidates with the same score - u32::max_value() + u32::MAX } else { score }, diff --git a/window/src/os/x11/cursor.rs b/window/src/os/x11/cursor.rs index a08725078..1b91a5d39 100644 --- a/window/src/os/x11/cursor.rs +++ b/window/src/os/x11/cursor.rs @@ -583,7 +583,7 @@ impl CursorInfo { let num_pixels = (width as usize) * (height as usize); ensure!( - num_pixels < u32::max_value() as usize, + num_pixels < u32::MAX as usize, "cursor image is larger than fits in u32" ); diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index 179207949..5fcbf929f 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -588,7 +588,7 @@ impl XWindowInner { property: conn.atom_xdndtypelist, r#type: xcb::x::ATOM_ATOM, long_offset: 0, - long_length: u32::max_value(), + long_length: u32::MAX, }) { Ok(prop) => prop.value::().to_vec(), Err(err) => { @@ -1107,7 +1107,7 @@ impl XWindowInner { property: selection.property(), r#type: selection.target(), long_offset: 0, - long_length: u32::max_value(), + long_length: u32::MAX, }) { Ok(prop) => { if let Some(mut promise) = self.copy_and_paste.request_mut(clipboard).take() { @@ -1149,7 +1149,7 @@ impl XWindowInner { property: selection.property(), r#type: selection.target(), long_offset: 0, - long_length: u32::max_value(), + long_length: u32::MAX, }) { Ok(prop) => { if selection.target() == conn.atom_utf8_string { diff --git a/window/src/os/x11/xsettings.rs b/window/src/os/x11/xsettings.rs index 5b26ef3f5..3a3bb8dd3 100644 --- a/window/src/os/x11/xsettings.rs +++ b/window/src/os/x11/xsettings.rs @@ -36,7 +36,7 @@ fn read_xsettings_grabbed( property: atom_xsettings_settings, r#type: atom_xsettings_settings, long_offset: 0, - long_length: u32::max_value(), + long_length: u32::MAX, })) .context("get_property")?;