1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

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

@@ -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);