Skip to content
Snippets Groups Projects
Commit 21bf1954 authored by Florian Blasius's avatar Florian Blasius
Browse files

Start manual merge of clippy changes.

parents 8a35fa7b 7f19a79e
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
# Generated by Cargo
# Cargo.lock
/target/
/crates/*/target/
.idea
*.iml
......
......@@ -81,10 +81,10 @@ impl shell::WindowAdapter for WindowAdapter {
match event.state {
shell::ButtonState::Up => self
.event_queue
.register_event(KeyUpEvent { event: event }, self.root),
.register_event(KeyUpEvent { event }, self.root),
shell::ButtonState::Down => self
.event_queue
.register_event(KeyDownEvent { event: event }, self.root),
.register_event(KeyDownEvent { event }, self.root),
}
}
......
......@@ -21,7 +21,7 @@ impl EventBox {
pub fn new<E: Event>(event: E, strategy: EventStrategy, source: Entity) -> Self {
EventBox {
event: Box::new(event),
source: source,
source,
event_type: TypeId::of::<E>(),
strategy,
}
......@@ -89,6 +89,10 @@ impl EventQueue {
pub fn len(&self) -> usize {
self.event_queue.len()
}
pub fn is_empty(&self) -> bool {
self.event_queue.is_empty()
}
}
impl<'a> IntoIterator for &'a mut EventQueue {
......
......@@ -31,11 +31,10 @@ impl Into<Rc<dyn EventHandler>> for KeyDownEventHandler {
impl EventHandler for KeyDownEventHandler {
fn handle_event(&self, event: &EventBox) -> bool {
if let Ok(event) = event.downcast_ref::<KeyDownEvent>() {
return (self.handler)(event.event.clone());
}
return false;
event
.downcast_ref::<KeyDownEvent>()
.ok()
.map_or(false, |event| (self.handler)(event.event.clone()))
}
fn handles_event(&self, event: &EventBox) -> bool {
......
......@@ -12,7 +12,7 @@ pub fn check_mouse_condition(mouse_position: Point, widget: &WidgetContainer<'_>
rect.set_x(position.x);
rect.set_y(position.y);
return rect.contains((mouse_position.x, mouse_position.y));
rect.contains((mouse_position.x, mouse_position.y))
}
pub struct MouseMoveEvent {
......@@ -66,11 +66,10 @@ impl Into<Rc<dyn EventHandler>> for ClickEventHandler {
impl EventHandler for ClickEventHandler {
fn handle_event(&self, event: &EventBox) -> bool {
if let Ok(event) = event.downcast_ref::<ClickEvent>() {
return (self.handler)(event.position);
}
return false;
event
.downcast_ref::<ClickEvent>()
.ok()
.map_or(false, |event| (self.handler)(event.position))
}
fn handles_event(&self, event: &EventBox) -> bool {
......@@ -91,11 +90,10 @@ impl Into<Rc<dyn EventHandler>> for MouseDownEventHandler {
impl EventHandler for MouseDownEventHandler {
fn handle_event(&self, event: &EventBox) -> bool {
if let Ok(event) = event.downcast_ref::<MouseDownEvent>() {
return (self.handler)(Point::new(event.x, event.y));
}
return false;
event
.downcast_ref::<MouseDownEvent>()
.ok()
.map_or(false, |event| (self.handler)(Point::new(event.x, event.y)))
}
fn handles_event(&self, event: &EventBox) -> bool {
......@@ -116,11 +114,10 @@ impl Into<Rc<dyn EventHandler>> for MouseUpEventHandler {
impl EventHandler for MouseUpEventHandler {
fn handle_event(&self, event: &EventBox) -> bool {
if let Ok(event) = event.downcast_ref::<MouseUpEvent>() {
return (self.handler)(Point::new(event.x, event.y));
}
return false;
event
.downcast_ref::<MouseUpEvent>()
.ok()
.map_or(false, |event| (self.handler)(Point::new(event.x, event.y)))
}
fn handles_event(&self, event: &EventBox) -> bool {
......@@ -140,11 +137,12 @@ impl Into<Rc<dyn EventHandler>> for ScrollEventHandler {
impl EventHandler for ScrollEventHandler {
fn handle_event(&self, event: &EventBox) -> bool {
if let Ok(event) = event.downcast_ref::<ScrollEvent>() {
return (self.handler)(Point::new(event.delta.x, event.delta.y));
}
return false;
event
.downcast_ref::<ScrollEvent>()
.ok()
.map_or(false, |event| {
(self.handler)(Point::new(event.delta.x, event.delta.y))
})
}
fn handles_event(&self, event: &EventBox) -> bool {
......
......@@ -39,7 +39,7 @@ impl Layout for FixedSizeLayout {
== Visibility::Collapsed
{
self.desired_size.borrow_mut().set_size(0.0, 0.0);
return self.desired_size.borrow().clone();
return self.desired_size.borrow();
}
let widget = WidgetContainer::new(entity, ecm, theme);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment