End statements with semicolon (clippy::semicolon_if_nothing_returned)

This commit is contained in:
Emil Ernerfeldt 2021-10-20 16:43:40 +02:00
parent ab3be8aca3
commit d97a369c44
35 changed files with 71 additions and 72 deletions

View file

@ -536,7 +536,7 @@ impl State {
}
if let Some(egui::Pos2 { x, y }) = output.text_cursor_pos {
window.set_ime_position(winit::dpi::LogicalPosition { x, y })
window.set_ime_position(winit::dpi::LogicalPosition { x, y });
}
}

View file

@ -213,7 +213,7 @@ impl Area {
if let Some((anchor, offset)) = anchor {
if is_new {
// unknown size
ctx.request_repaint()
ctx.request_repaint();
} else {
let screen = ctx.available_rect();
state.pos = anchor.align_size_within_rect(state.size, screen).min + offset;

View file

@ -37,7 +37,7 @@ impl Output {
/// Open the given url in a web browser.
/// If egui is running in a browser, the same tab will be reused.
pub fn open_url(&mut self, url: impl ToString) {
self.open_url = Some(OpenUrl::same_tab(url))
self.open_url = Some(OpenUrl::same_tab(url));
}
/// This can be used by a text-to-speech system to describe the events (if any).

View file

@ -76,39 +76,39 @@ pub struct IdHasher(u64);
impl std::hash::Hasher for IdHasher {
fn write(&mut self, _: &[u8]) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_u8(&mut self, _n: u8) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_u16(&mut self, _n: u16) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_u32(&mut self, _n: u32) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_u64(&mut self, n: u64) {
self.0 = n
self.0 = n;
}
fn write_usize(&mut self, _n: usize) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_i8(&mut self, _n: i8) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_i16(&mut self, _n: i16) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_i32(&mut self, _n: i32) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_i64(&mut self, _n: i64) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn write_isize(&mut self, _n: isize) {
unreachable!("Invalid use of IdHasher")
unreachable!("Invalid use of IdHasher");
}
fn finish(&self) -> u64 {

View file

@ -687,7 +687,7 @@ impl InputState {
for (device_id, touch_state) in touch_states {
ui.collapsing(format!("Touch State [device {}]", device_id.0), |ui| {
touch_state.ui(ui)
touch_state.ui(ui);
});
}

View file

@ -128,7 +128,7 @@ impl PaintList {
pub fn extend(&mut self, clip_rect: Rect, mut shapes: Vec<Shape>) {
self.0
.extend(shapes.drain(..).map(|shape| ClippedShape(clip_rect, shape)))
.extend(shapes.drain(..).map(|shape| ClippedShape(clip_rect, shape)));
}
/// Modify an existing [`Shape`].

View file

@ -72,7 +72,7 @@ impl Painter {
/// If `false`, nothing added to the painter will be visible
pub(crate) fn set_invisible(&mut self) {
self.fade_to_color = Some(Color32::TRANSPARENT)
self.fade_to_color = Some(Color32::TRANSPARENT);
}
/// Create a painter for a sub-region of this `Painter`.
@ -189,7 +189,7 @@ impl Painter {
}
let mut shape = shape.into();
self.transform_shape(&mut shape);
self.paint_list.lock().set(idx, self.clip_rect, shape)
self.paint_list.lock().set(idx, self.clip_rect, shape);
}
}

View file

@ -70,7 +70,7 @@ impl Placer {
#[inline(always)]
pub(crate) fn set_cursor(&mut self, cursor: Rect) {
self.region.cursor = cursor
self.region.cursor = cursor;
}
}
@ -162,14 +162,14 @@ impl Placer {
self.region.sanity_check();
if let Some(grid) = &mut self.grid {
grid.advance(&mut self.region.cursor, frame_rect, widget_rect)
grid.advance(&mut self.region.cursor, frame_rect, widget_rect);
} else {
self.layout.advance_after_rects(
&mut self.region.cursor,
frame_rect,
widget_rect,
item_spacing,
)
);
}
self.expand_to_include_rect(frame_rect); // e.g. for centered layouts: pretend we used whole frame
@ -181,9 +181,9 @@ impl Placer {
/// Otherwise does nothing.
pub(crate) fn end_row(&mut self, item_spacing: Vec2, painter: &Painter) {
if let Some(grid) = &mut self.grid {
grid.end_row(&mut self.region.cursor, painter)
grid.end_row(&mut self.region.cursor, painter);
} else {
self.layout.end_row(&mut self.region, item_spacing)
self.layout.end_row(&mut self.region, item_spacing);
}
}
@ -272,7 +272,7 @@ impl Placer {
painter.debug_text(align.pos_in_rect(&rect), align, stroke.color, text);
} else {
self.layout
.paint_text_at_cursor(painter, &self.region, stroke, text)
.paint_text_at_cursor(painter, &self.region, stroke, text);
}
}
}

View file

@ -210,12 +210,12 @@ impl Response {
/// Request that this widget get keyboard focus.
pub fn request_focus(&self) {
self.ctx.memory().request_focus(self.id)
self.ctx.memory().request_focus(self.id);
}
/// Surrender keyboard focus for this widget.
pub fn surrender_focus(&self) {
self.ctx.memory().surrender_focus(self.id)
self.ctx.memory().surrender_focus(self.id);
}
/// The widgets is being dragged.

View file

@ -748,23 +748,23 @@ impl Widgets {
ui.label(
"The style of a widget that you cannot interact with, e.g. labels and separators.",
);
noninteractive.ui(ui)
noninteractive.ui(ui);
});
ui.collapsing("Interactive but inactive", |ui| {
ui.label("The style of an interactive widget, such as a button, at rest.");
inactive.ui(ui)
inactive.ui(ui);
});
ui.collapsing("Interactive and hovered", |ui| {
ui.label("The style of an interactive widget while you hover it.");
hovered.ui(ui)
hovered.ui(ui);
});
ui.collapsing("Interactive and active", |ui| {
ui.label("The style of an interactive widget as you are clicking or dragging it.");
active.ui(ui)
active.ui(ui);
});
ui.collapsing("Open menu", |ui| {
ui.label("The style of an open combo-box or menu button");
open.ui(ui)
open.ui(ui);
});
// ui.vertical_centered(|ui| reset_button(ui, self));

View file

@ -381,7 +381,7 @@ impl Ui {
/// Used for animation, kind of hacky
pub(crate) fn force_set_min_rect(&mut self, min_rect: Rect) {
self.placer.force_set_min_rect(min_rect)
self.placer.force_set_min_rect(min_rect);
}
// ------------------------------------------------------------------------
@ -432,13 +432,13 @@ impl Ui {
/// so further widgets will try not to be wider than previous widgets.
/// Useful for normal vertical layouts.
pub fn shrink_width_to_current(&mut self) {
self.set_max_width(self.min_rect().width())
self.set_max_width(self.min_rect().width());
}
/// Helper: shrinks the max height to the current height,
/// so further widgets will try not to be wider than previous widgets.
pub fn shrink_height_to_current(&mut self) {
self.set_max_height(self.min_rect().height())
self.set_max_height(self.min_rect().height());
}
/// Expand the `min_rect` and `max_rect` of this ui to include a child at the given rect.
@ -741,7 +741,7 @@ impl Ui {
}
pub(crate) fn set_cursor(&mut self, cursor: Rect) {
self.placer.set_cursor(cursor)
self.placer.set_cursor(cursor);
}
/// Where do we expect a zero-sized widget to be placed?

View file

@ -89,7 +89,7 @@ impl<Value: 'static + Send + Sync, Computer: 'static + Send + Sync> CacheTrait
for FrameCache<Value, Computer>
{
fn update(&mut self) {
self.evice_cache()
self.evice_cache();
}
fn len(&self) -> usize {

View file

@ -119,7 +119,7 @@ where
#[inline]
pub fn clear(&mut self) {
self.values.clear()
self.values.clear();
}
/// Values must be added with a monotonically increasing time, or at least not decreasing.

View file

@ -61,7 +61,7 @@ impl<'a> DragValue<'a> {
pub fn new<Num: emath::Numeric>(value: &'a mut Num) -> Self {
let slf = Self::from_get_set(move |v: Option<f64>| {
if let Some(v) = v {
*value = Num::from_f64(v)
*value = Num::from_f64(v);
}
value.to_f64()
});
@ -198,7 +198,7 @@ impl<'a> Widget for DragValue<'a> {
);
if let Ok(parsed_value) = value_text.parse() {
let parsed_value = clamp_to_range(parsed_value, clamp_range);
set(&mut get_set_value, parsed_value)
set(&mut get_set_value, parsed_value);
}
if ui.input().key_pressed(Key::Enter) {
ui.memory().surrender_focus(kb_edit_id);

View file

@ -89,7 +89,7 @@ impl LineStyle {
if highlight {
radius *= 2f32.sqrt();
}
shapes.extend(Shape::dotted_line(&line, stroke.color, *spacing, radius))
shapes.extend(Shape::dotted_line(&line, stroke.color, *spacing, radius));
}
LineStyle::Dashed { length } => {
if highlight {
@ -101,7 +101,7 @@ impl LineStyle {
stroke,
*length,
length * golden_ratio,
))
));
}
}
}
@ -308,7 +308,7 @@ impl PlotItem for VLine {
transform.position_from_value(&Value::new(*x, transform.bounds().min[1])),
transform.position_from_value(&Value::new(*x, transform.bounds().max[1])),
];
style.style_line(points, *stroke, *highlight, shapes)
style.style_line(points, *stroke, *highlight, shapes);
}
fn initialize(&mut self, _x_range: RangeInclusive<f64>) {}
@ -1395,7 +1395,7 @@ impl PlotItem for PlotImage {
rect,
0.0,
Stroke::new(1.0, ui.visuals().strong_text_color()),
))
));
}
}

View file

@ -452,7 +452,7 @@ impl Widget for Plot {
bounds.make_x_symmetrical();
};
if center_y_axis {
bounds.make_y_symmetrical()
bounds.make_y_symmetrical();
};
let mut transform = ScreenTransform::new(rect, bounds, center_x_axis, center_y_axis);

View file

@ -71,7 +71,7 @@ impl<'a> Slider<'a> {
let range_f64 = range.start().to_f64()..=range.end().to_f64();
let slf = Self::from_get_set(range_f64, move |v: Option<f64>| {
if let Some(v) = v {
*value = Num::from_f64(v)
*value = Num::from_f64(v);
}
value.to_f64()
});

View file

@ -455,7 +455,7 @@ impl<'t> Widget for TextEdit<'t> {
let frame_rect = response.rect.expand2(margin);
ui.allocate_space(frame_rect.size());
if interactive {
response |= ui.interact(frame_rect, id, Sense::click())
response |= ui.interact(frame_rect, id, Sense::click());
}
if response.clicked() && !response.lost_focus() {
ui.memory().request_focus(response.id);

View file

@ -22,7 +22,7 @@ impl epi::App for DemoApp {
) {
#[cfg(feature = "persistence")]
if let Some(storage) = _storage {
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default()
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default();
}
}

View file

@ -69,7 +69,7 @@ impl EasyMarkEditor {
} else {
ScrollArea::vertical()
.id_source("source")
.show(ui, |ui| self.editor_ui(ui))
.show(ui, |ui| self.editor_ui(ui));
}
}

View file

@ -15,7 +15,7 @@ impl MemoizedEasymarkHighlighter {
if (&self.visuals, self.code.as_str()) != (visuals, code) {
self.visuals = visuals.clone();
self.code = code.to_owned();
self.output = highlight_easymark(visuals, code)
self.output = highlight_easymark(visuals, code);
}
self.output.clone()
}

View file

@ -3,7 +3,7 @@ use egui::*;
/// Parse and display a VERY simple and small subset of Markdown.
pub fn easy_mark(ui: &mut Ui, easy_mark: &str) {
easy_mark_it(ui, easy_mark::Parser::new(easy_mark))
easy_mark_it(ui, easy_mark::Parser::new(easy_mark));
}
pub fn easy_mark_it<'em>(ui: &mut Ui, items: impl Iterator<Item = easy_mark::Item<'em>>) {

View file

@ -50,7 +50,7 @@ impl epi::App for WrapApp {
) {
#[cfg(feature = "persistence")]
if let Some(storage) = _storage {
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default()
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default();
}
}

View file

@ -16,7 +16,7 @@ impl epi::TextureAllocator for Painter {
}
fn free(&mut self, id: egui::TextureId) {
self.free_user_texture(id)
self.free_user_texture(id);
}
}

View file

@ -109,7 +109,7 @@ impl Painter {
self.upload_pending_user_textures(display);
for egui::ClippedMesh(clip_rect, mesh) in cipped_meshes {
self.paint_mesh(target, display, pixels_per_point, clip_rect, &mesh)
self.paint_mesh(target, display, pixels_per_point, clip_rect, &mesh);
}
}

View file

@ -16,7 +16,7 @@ impl epi::TextureAllocator for Painter {
}
fn free(&mut self, id: egui::TextureId) {
self.free_user_texture(id)
self.free_user_texture(id);
}
}

View file

@ -200,6 +200,6 @@ impl EguiGlow {
}
pub fn destroy(&mut self, gl: &glow::Context) {
self.painter.destroy(gl)
self.painter.destroy(gl);
}
}

View file

@ -365,7 +365,7 @@ impl Painter {
let size_in_pixels = unsafe { self.prepare_painting(gl_window, gl, pixels_per_point) };
for egui::ClippedMesh(clip_rect, mesh) in clipped_meshes {
self.paint_mesh(gl, size_in_pixels, pixels_per_point, clip_rect, &mesh)
self.paint_mesh(gl, size_in_pixels, pixels_per_point, clip_rect, &mesh);
}
assert_eq!(

View file

@ -188,11 +188,11 @@ macro_rules! epaint_assert {
#[inline(always)]
pub(crate) fn f32_hash<H: std::hash::Hasher>(state: &mut H, f: f32) {
if f == 0.0 {
state.write_u8(0)
state.write_u8(0);
} else if f.is_nan() {
state.write_u8(1)
state.write_u8(1);
} else {
use std::hash::Hash;
f.to_bits().hash(state)
f.to_bits().hash(state);
}
}

View file

@ -170,7 +170,7 @@ impl Mesh {
#[inline(always)]
pub fn add_colored_rect(&mut self, rect: Rect, color: Color32) {
crate::epaint_assert!(self.texture_id == TextureId::Egui);
self.add_rect_with_uv(rect, [WHITE_UV, WHITE_UV].into(), color)
self.add_rect_with_uv(rect, [WHITE_UV, WHITE_UV].into(), color);
}
/// This is for platforms that only support 16-bit index buffers.

View file

@ -44,7 +44,7 @@ impl<T> Mutex<T> {
// Store it in thread local storage while we have a lock guard taken out
HELD_LOCKS_TLS.with(|locks| {
if locks.borrow().contains(&ptr) {
panic!("Recursively locking a Mutex in the same thread is not supported")
panic!("Recursively locking a Mutex in the same thread is not supported");
} else {
locks.borrow_mut().insert(ptr);
}

View file

@ -6,7 +6,7 @@ pub fn adjust_colors(shape: &mut Shape, adjust_color: &impl Fn(&mut Color32)) {
Shape::Noop => {}
Shape::Vec(shapes) => {
for shape in shapes {
adjust_colors(shape, adjust_color)
adjust_colors(shape, adjust_color);
}
}
Shape::Circle(circle_shape) => {

View file

@ -196,7 +196,6 @@ impl PaintStats {
}
}
Shape::Noop | Shape::Circle { .. } | Shape::LineSegment { .. } | Shape::Rect { .. } => {
Default::default()
}
Shape::Path(path_shape) => {
self.shape_path += AllocInfo::from_slice(&path_shape.points);

View file

@ -41,7 +41,7 @@ impl Path {
#[inline(always)]
pub fn reserve(&mut self, additional: usize) {
self.0.reserve(additional)
self.0.reserve(additional);
}
#[inline(always)]
@ -153,12 +153,12 @@ impl Path {
/// Open-ended.
pub fn stroke_open(&self, stroke: Stroke, options: &TessellationOptions, out: &mut Mesh) {
stroke_path(&self.0, PathType::Open, stroke, options, out)
stroke_path(&self.0, PathType::Open, stroke, options, out);
}
/// A closed path (returning to the first point).
pub fn stroke_closed(&self, stroke: Stroke, options: &TessellationOptions, out: &mut Mesh) {
stroke_path(&self.0, PathType::Closed, stroke, options, out)
stroke_path(&self.0, PathType::Closed, stroke, options, out);
}
pub fn stroke(
@ -168,12 +168,12 @@ impl Path {
options: &TessellationOptions,
out: &mut Mesh,
) {
stroke_path(&self.0, path_type, stroke, options, out)
stroke_path(&self.0, path_type, stroke, options, out);
}
/// The path is taken to be closed (i.e. returning to the start again).
pub fn fill(&self, color: Color32, options: &TessellationOptions, out: &mut Mesh) {
fill_closed_path(&self.0, color, options, out)
fill_closed_path(&self.0, color, options, out);
}
}
@ -549,7 +549,7 @@ impl Tessellator {
Shape::Noop => {}
Shape::Vec(vec) => {
for shape in vec {
self.tessellate_shape(tex_size, shape, out)
self.tessellate_shape(tex_size, shape, out);
}
}
Shape::Circle(CircleShape {
@ -837,7 +837,7 @@ pub fn tessellate_shapes(
Stroke::new(2.0, Color32::from_rgb(150, 255, 150)),
),
mesh,
)
);
}
}

View file

@ -34,7 +34,7 @@ pub fn layout(fonts: &Fonts, job: Arc<LayoutJob>) -> Galley {
for (i, row) in rows.iter_mut().enumerate() {
let is_last_row = i + 1 == num_rows;
let justify_row = justify && !row.ends_with_newline && !is_last_row;
halign_and_jusitfy_row(fonts, row, job.halign, job.wrap_width, justify_row)
halign_and_jusitfy_row(fonts, row, job.halign, job.wrap_width, justify_row);
}
}
@ -74,7 +74,7 @@ fn layout_section(
let (font_impl, glyph_info) = font.glyph_info_and_font_impl(chr);
if let Some(font_impl) = font_impl {
if let Some(last_glyph_id) = last_glyph_id {
paragraph.cursor_x += font_impl.pair_kerning(last_glyph_id, glyph_info.id)
paragraph.cursor_x += font_impl.pair_kerning(last_glyph_id, glyph_info.id);
}
}