Make clippy happy

This commit is contained in:
Héctor Ramón Jiménez 2019-08-31 06:20:56 +02:00
parent 1cd96d0d61
commit 6fbba6f4ee
8 changed files with 31 additions and 28 deletions

View File

@ -1,4 +1,5 @@
/// The hasher used to compare layouts.
#[derive(Debug)]
pub struct Hasher(twox_hash::XxHash64);
impl Default for Hasher {

View File

@ -1,6 +1,11 @@
/// The symbolic name of a keyboard key
/// The symbolic name of a keyboard key.
///
/// This is mostly the `KeyCode` type found in `winit`. If you are using
/// `winit`, consider enabling the `winit` feature to get conversion
/// implementations for free!
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]
#[repr(u32)]
#[allow(missing_docs)]
pub enum KeyCode {
/// The '1' key over the letters.
Key1,
@ -50,7 +55,7 @@ pub enum KeyCode {
Y,
Z,
/// The Escape key, next to F1.
/// The Escape key, next to F1
Escape,
F1,
@ -78,14 +83,14 @@ pub enum KeyCode {
F23,
F24,
/// Print Screen/SysRq.
/// Print Screen/SysRq
Snapshot,
/// Scroll Lock.
/// Scroll Lock
Scroll,
/// Pause/Break key, next to Scroll lock.
/// Pause/Break key, next to Scroll lock
Pause,
/// `Insert`, next to Backspace.
/// `Insert`, next to Backspace
Insert,
Home,
Delete,
@ -98,15 +103,11 @@ pub enum KeyCode {
Right,
Down,
/// The Backspace key, right over Enter.
// TODO: rename
Back,
/// The Enter key.
Return,
/// The space bar.
Backspace,
Enter,
Space,
/// The "Compose" key on Linux.
/// The "Compose" key on Linux
Compose,
Caret,

View File

@ -191,8 +191,8 @@
//! [documentation]: https://docs.rs/iced
//! [examples]: https://github.com/hecrj/iced/tree/master/examples
//! [`UserInterface`]: struct.UserInterface.html
//#![deny(missing_docs)]
//#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![deny(unused_results)]
#![deny(unsafe_code)]
#![deny(rust_2018_idioms)]

View File

@ -3,7 +3,10 @@ use crate::Vector;
/// A 2D point.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Point {
/// The X coordinate.
pub x: f32,
/// The Y coordinate.
pub y: f32,
}

View File

@ -11,6 +11,7 @@ use stretch::result;
/// charge of using this type in your system in any way you want.
///
/// [`Layout`]: struct.Layout.html
#[derive(Debug)]
pub struct UserInterface<'a, Message, Renderer> {
hash: u64,
root: Element<'a, Message, Renderer>,
@ -173,11 +174,8 @@ impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> {
let mut messages = Vec::new();
for event in events {
match event {
Event::Mouse(mouse::Event::CursorMoved { x, y }) => {
self.cursor_position = Point::new(x, y);
}
_ => {}
if let Event::Mouse(mouse::Event::CursorMoved { x, y }) = event {
self.cursor_position = Point::new(x, y);
}
self.root.widget.on_event(
@ -257,13 +255,11 @@ impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> {
/// }
/// ```
pub fn draw(&self, renderer: &mut Renderer) -> MouseCursor {
let cursor = self.root.widget.draw(
self.root.widget.draw(
renderer,
Layout::new(&self.layout),
self.cursor_position,
);
cursor
)
}
/// Extract the [`Cache`] of the [`UserInterface`], consuming it in the

View File

@ -10,6 +10,7 @@ use crate::{
/// A [`Column`] will try to fill the horizontal space of its container.
///
/// [`Column`]: struct.Column.html
#[derive(Default)]
pub struct Column<'a, Message, Renderer> {
style: Style,
spacing: u16,
@ -144,7 +145,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
let mut style = node.0.style();
style.margin.bottom =
stretch::style::Dimension::Points(self.spacing as f32);
stretch::style::Dimension::Points(f32::from(self.spacing));
node.0.set_style(style);
node

View File

@ -10,6 +10,7 @@ use crate::{
/// A [`Row`] will try to fill the horizontal space of its container.
///
/// [`Row`]: struct.Row.html
#[derive(Default)]
pub struct Row<'a, Message, Renderer> {
style: Style,
spacing: u16,
@ -141,7 +142,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
let mut style = node.0.style();
style.margin.end =
stretch::style::Dimension::Points(self.spacing as f32);
stretch::style::Dimension::Points(f32::from(self.spacing));
node.0.set_style(style);
node

View File

@ -112,7 +112,7 @@ where
Renderer: self::Renderer<Color>,
{
fn node(&self, renderer: &Renderer) -> Node {
renderer.node(self.style, &self.content, self.size as f32)
renderer.node(self.style, &self.content, f32::from(self.size))
}
fn draw(
@ -124,7 +124,7 @@ where
renderer.draw(
layout.bounds(),
&self.content,
self.size as f32,
f32::from(self.size),
self.color,
self.horizontal_alignment,
self.vertical_alignment,