Fix clippy warnings

This commit is contained in:
Alexandre Bury 2018-04-10 11:53:25 -07:00
parent b1e9afe0ff
commit a355171844
14 changed files with 40 additions and 32 deletions

View File

@ -159,7 +159,7 @@ impl Backend {
let make_event = |event| Event::Mouse {
offset: Vec2::zero(),
position: Vec2::new(mevent.x as usize, mevent.y as usize),
event: event,
event,
};
if mevent.bstate == ncurses::REPORT_MOUSE_POSITION as mmask_t {
@ -239,7 +239,8 @@ impl backend::Backend for Backend {
if current != colors {
self.set_colors(colors);
}
return current;
current
}
fn set_effect(&self, effect: Effect) {

View File

@ -569,7 +569,7 @@ impl Cursive {
}
let printer =
Printer::new(self.screen_size(), &self.theme, &self.backend);
Printer::new(self.screen_size(), &self.theme, &*self.backend);
let selected = self.menubar.receive_events();

View File

@ -24,7 +24,7 @@ pub struct Printer<'a> {
/// `true` if nothing has been drawn yet.
new: Rc<Cell<bool>>,
/// Backend used to actually draw things
backend: &'a Box<Backend>,
backend: &'a Backend,
}
impl<'a> Printer<'a> {
@ -33,15 +33,15 @@ impl<'a> Printer<'a> {
/// But nobody needs to know that.
#[doc(hidden)]
pub fn new<T: Into<Vec2>>(
size: T, theme: &'a Theme, backend: &'a Box<Backend>
size: T, theme: &'a Theme, backend: &'a Backend
) -> Self {
Printer {
offset: Vec2::zero(),
size: size.into(),
focused: true,
theme: theme,
theme,
new: Rc::new(Cell::new(true)),
backend: backend,
backend,
}
}

View File

@ -1,5 +1,5 @@
use vec::Vec2;
use std::ops::{Add, Div, Mul, Sub};
use vec::Vec2;
/// Four values representing each direction.
#[derive(Clone, Copy)]
@ -18,10 +18,10 @@ impl Margins {
/// Creates a new Margins.
pub fn new(left: usize, right: usize, top: usize, bottom: usize) -> Self {
Margins {
left: left,
right: right,
top: top,
bottom: bottom,
left,
right,
top,
bottom,
}
}
@ -52,25 +52,34 @@ impl Margins {
}
impl From<(usize, usize, usize, usize)> for Margins {
fn from((left, right, top, bottom): (usize, usize, usize, usize)) -> Margins {
fn from(
(left, right, top, bottom): (usize, usize, usize, usize),
) -> Margins {
Margins::new(left, right, top, bottom)
}
}
impl From<(i32, i32, i32, i32)> for Margins {
fn from((left, right, top, bottom): (i32, i32, i32, i32)) -> Margins {
(left as usize, right as usize, top as usize, bottom as usize).into()
(
left as usize,
right as usize,
top as usize,
bottom as usize,
).into()
}
}
impl From<((i32, i32), (i32, i32))> for Margins {
fn from(((left, right), (top, bottom)): ((i32, i32), (i32, i32))) -> Margins {
fn from(
((left, right), (top, bottom)): ((i32, i32), (i32, i32)),
) -> Margins {
(left, right, top, bottom).into()
}
}
impl From<((usize, usize), (usize, usize))> for Margins {
fn from(
((left, right), (top, bottom)): ((usize, usize), (usize, usize))
((left, right), (top, bottom)): ((usize, usize), (usize, usize)),
) -> Margins {
(left, right, top, bottom).into()
}
@ -131,5 +140,3 @@ impl Mul<usize> for Margins {
}
}
}

View File

@ -1,5 +1,5 @@
use XY;
use vec::Vec2;
use XY;
/// Cache around a one-dimensional layout result.
///
@ -19,8 +19,8 @@ impl SizeCache {
/// Creates a new sized cache
pub fn new(value: usize, constrained: bool) -> Self {
SizeCache {
value: value,
constrained: constrained,
value,
constrained,
}
}

View File

@ -44,7 +44,7 @@ impl<T: View> BoxView<T> {
BoxView {
size: (width, height).into(),
squishable: false,
view: view,
view,
}
}

View File

@ -48,7 +48,7 @@ impl<T> Canvas<T> {
/// ```
pub fn new(state: T) -> Self {
Canvas {
state: state,
state,
draw: Box::new(|_, _| ()),
on_event: Box::new(|_, _| EventResult::Ignored),
required_size: Box::new(|_, _| Vec2::new(1, 1)),

View File

@ -113,7 +113,7 @@ impl LinearLayout {
pub fn new(orientation: direction::Orientation) -> Self {
LinearLayout {
children: Vec::new(),
orientation: orientation,
orientation,
focus: 0,
cache: None,
}

View File

@ -26,7 +26,7 @@ impl MenuPopup {
/// Creates a new `MenuPopup` using the given menu tree.
pub fn new(menu: Rc<MenuTree>) -> Self {
MenuPopup {
menu: menu,
menu,
focus: 0,
scrollbase: ScrollBase::new().scrollbar_offset(1).right_padding(0),
align: Align::top_left(),

View File

@ -72,7 +72,7 @@ impl<T: View> OnEventView<T> {
/// Wraps the given view in a new OnEventView.
pub fn new(view: T) -> Self {
OnEventView {
view: view,
view,
callbacks: HashMap::new(),
}
}

View File

@ -12,7 +12,7 @@ pub struct Panel<V: View> {
impl<V: View> Panel<V> {
/// Creates a new panel around the given view.
pub fn new(view: V) -> Self {
Panel { view: view }
Panel { view }
}
inner_getters!(self.view: V);

View File

@ -107,10 +107,10 @@ impl<T> RadioButton<T> {
state: Rc<RefCell<SharedState<T>>>, id: usize, label: String
) -> Self {
RadioButton {
state: state,
id: id,
state,
id,
enabled: true,
label: label,
label,
}
}

View File

@ -341,7 +341,7 @@ impl<T: 'static> SelectView<T> {
// TODO: Check if `i >= self.len()` ?
// assert!(i < self.len(), "SelectView: trying to select out-of-bound");
// Or just cap the ID?
let i = if self.len() == 0 {
let i = if self.is_empty() {
0
} else {
min(i, self.len() - 1)

View File

@ -13,7 +13,7 @@ pub struct XY<T> {
impl<T> XY<T> {
/// Creates a new `XY` from the given values.
pub fn new(x: T, y: T) -> Self {
XY { x: x, y: y }
XY { x, y }
}
/// Creates a new `XY` by applying `f` to `x` and `y`.