Clippy fixes

This commit is contained in:
Emil Ernerfeldt 2022-03-21 21:48:35 +01:00
parent 339b28b470
commit 5c68edbb15
7 changed files with 20 additions and 13 deletions

View file

@ -7,6 +7,7 @@
//! * [`three-d`](https://github.com/asny/three-d)
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(unsafe_code)]
use eframe::egui;
@ -57,7 +58,7 @@ impl eframe::App for MyApp {
}
fn on_exit(&mut self, gl: &glow::Context) {
self.rotating_triangle.lock().destroy(gl)
self.rotating_triangle.lock().destroy(gl);
}
}

View file

@ -50,6 +50,7 @@ impl eframe::App for MyApp {
}
}
#[allow(clippy::needless_pass_by_value)]
fn parse_response(response: ehttp::Response) -> Result<RetainedImage, String> {
let content_type = response.content_type().unwrap_or_default();
if content_type.starts_with("image/") {

View file

@ -1,3 +1,5 @@
//! Demo app for egui
#[cfg(target_arch = "wasm32")]
use eframe::wasm_bindgen::{self, prelude::*};

View file

@ -1,3 +1,5 @@
//! Demo app for egui
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
// When compiling natively:

View file

@ -17,7 +17,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
demo_windows.ui(ctx);
});
ctx.tessellate(full_output.shapes)
})
});
});
c.bench_function("demo_no_tessellate", |b| {
@ -25,14 +25,14 @@ pub fn criterion_benchmark(c: &mut Criterion) {
ctx.run(RawInput::default(), |ctx| {
demo_windows.ui(ctx);
})
})
});
});
let full_output = ctx.run(RawInput::default(), |ctx| {
demo_windows.ui(ctx);
});
c.bench_function("demo_only_tessellate", |b| {
b.iter(|| ctx.tessellate(full_output.shapes.clone()))
b.iter(|| ctx.tessellate(full_output.shapes.clone()));
});
}
@ -45,7 +45,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
ctx.run(RawInput::default(), |ctx| {
demo_windows.ui(ctx);
})
})
});
});
}
@ -56,12 +56,12 @@ pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("label &str", |b| {
b.iter(|| {
ui.label("the quick brown fox jumps over the lazy dog");
})
});
});
c.bench_function("label format!", |b| {
b.iter(|| {
ui.label("the quick brown fox jumps over the lazy dog".to_owned());
})
});
});
});
});
@ -77,7 +77,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let rect = ui.max_rect();
b.iter(|| {
painter.rect(rect, 2.0, egui::Color32::RED, (1.0, egui::Color32::WHITE));
})
});
});
});
@ -108,7 +108,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
wrap_width,
);
layout(&mut locked_fonts.fonts, job.into())
})
});
});
}
c.bench_function("text_layout_cached", |b| {
@ -119,7 +119,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
color,
wrap_width,
)
})
});
});
let galley = fonts.layout(LOREM_IPSUM_LONG.to_owned(), font_id, color, wrap_width);
@ -131,7 +131,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
b.iter(|| {
tessellator.tessellate_text(font_image_size, &text_shape, &mut mesh);
mesh.clear();
})
});
});
}
}

View file

@ -1,4 +1,4 @@
//! Example how to use [epi::NativeTexture] with glium.
//! Example how to use [`epi::NativeTexture`] with glium.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
@ -111,7 +111,7 @@ fn create_display(event_loop: &glutin::event_loop::EventLoop<()>) -> glium::Disp
glium::Display::new(window_builder, context_builder, event_loop).unwrap()
}
fn load_glium_image(png_data: &[u8]) -> glium::texture::RawImage2d<u8> {
fn load_glium_image(png_data: &[u8]) -> glium::texture::RawImage2d<'_, u8> {
// Load image using the image crate:
let image = image::load_from_memory(png_data).unwrap().to_rgba8();
let image_dimensions = image.dimensions();

View file

@ -1,6 +1,7 @@
//! Example how to use pure `egui_glow` without [`epi`].
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(unsafe_code)]
fn main() {
let mut clear_color = [0.1, 0.1, 0.1];