Skip to content

Commit

Permalink
Fix clippy issues from 1.74 (#3558)
Browse files Browse the repository at this point in the history
Nothing major
  • Loading branch information
emilk authored Nov 16, 2023
1 parent a243180 commit f01b2b7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 20 deletions.
6 changes: 3 additions & 3 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl ContextImpl {
}

fn request_repaint_after(&mut self, delay: Duration, viewport_id: ViewportId) {
let mut viewport = self.viewports.entry(viewport_id).or_default();
let viewport = self.viewports.entry(viewport_id).or_default();

// Each request results in two repaints, just to give some things time to settle.
// This solves some corner-cases of missing repaints on frame-delayed responses.
Expand Down Expand Up @@ -2607,7 +2607,7 @@ impl Context {
ctx.viewport_parents
.insert(new_viewport_id, ctx.viewport_id());

let mut viewport = ctx.viewports.entry(new_viewport_id).or_default();
let viewport = ctx.viewports.entry(new_viewport_id).or_default();
viewport.class = ViewportClass::Deferred;
viewport.builder = viewport_builder;
viewport.used = true;
Expand Down Expand Up @@ -2666,7 +2666,7 @@ impl Context {
ctx.viewport_parents
.insert(new_viewport_id, parent_viewport_id);

let mut viewport = ctx.viewports.entry(new_viewport_id).or_default();
let viewport = ctx.viewports.entry(new_viewport_id).or_default();
viewport.builder = builder.clone();
viewport.used = true;
viewport.viewport_ui_cb = None; // it is immediate
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/util/id_type_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl std::fmt::Debug for Element {
match &self {
Self::Value { value, .. } => f
.debug_struct("Element::Value")
.field("type_id", &value.type_id())
.field("type_id", &(**value).type_id())
.finish_non_exhaustive(),
Self::Serialized(SerializedElement {
type_id,
Expand Down
9 changes: 3 additions & 6 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,9 @@ impl<'t> TextEdit<'t> {
let glyph_count = row.glyphs.len();
let mut value = String::new();
value.reserve(glyph_count);
let mut character_lengths = Vec::<u8>::new();
character_lengths.reserve(glyph_count);
let mut character_positions = Vec::<f32>::new();
character_positions.reserve(glyph_count);
let mut character_widths = Vec::<f32>::new();
character_widths.reserve(glyph_count);
let mut character_lengths = Vec::<u8>::with_capacity(glyph_count);
let mut character_positions = Vec::<f32>::with_capacity(glyph_count);
let mut character_widths = Vec::<f32>::with_capacity(glyph_count);
let mut word_lengths = Vec::<u8>::new();
let mut was_at_word_end = false;
let mut last_word_start = 0usize;
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/ehttp_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct EhttpLoader {
}

impl EhttpLoader {
pub const ID: &str = egui::generate_loader_id!(EhttpLoader);
pub const ID: &'static str = egui::generate_loader_id!(EhttpLoader);
}

const PROTOCOLS: &[&str] = &["http://", "https://"];
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/file_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct FileLoader {
}

impl FileLoader {
pub const ID: &str = egui::generate_loader_id!(FileLoader);
pub const ID: &'static str = egui::generate_loader_id!(FileLoader);
}

const PROTOCOL: &str = "file://";
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct ImageCrateLoader {
}

impl ImageCrateLoader {
pub const ID: &str = egui::generate_loader_id!(ImageCrateLoader);
pub const ID: &'static str = egui::generate_loader_id!(ImageCrateLoader);
}

fn is_supported_uri(uri: &str) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/loaders/svg_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct SvgLoader {
}

impl SvgLoader {
pub const ID: &str = egui::generate_loader_id!(SvgLoader);
pub const ID: &'static str = egui::generate_loader_id!(SvgLoader);
}

fn is_supported(uri: &str) -> bool {
Expand Down
9 changes: 3 additions & 6 deletions crates/epaint/src/util/ordered_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,16 @@ impl<T: Float> PartialEq<Self> for OrderedFloat<T> {
impl<T: Float> PartialOrd<Self> for OrderedFloat<T> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match self.0.partial_cmp(&other.0) {
Some(ord) => Some(ord),
None => Some(self.0.is_nan().cmp(&other.0.is_nan())),
}
Some(self.cmp(other))
}
}

impl<T: Float> Ord for OrderedFloat<T> {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
match self.partial_cmp(other) {
match self.0.partial_cmp(&other.0) {
Some(ord) => ord,
None => unreachable!(),
None => self.0.is_nan().cmp(&other.0.is_nan()),
}
}
}
Expand Down

0 comments on commit f01b2b7

Please sign in to comment.