fix clippy warnings

This commit is contained in:
Jay Jackson 2022-05-16 21:41:33 -04:00 committed by Rafael Carício
parent 37950d6e2e
commit ade4ae5a2d
5 changed files with 20 additions and 23 deletions

View file

@ -303,21 +303,21 @@ impl Rusty for LvArg {
#[derive(Clone)] #[derive(Clone)]
pub struct LvType { pub struct LvType {
literal_name: String, literal_name: String,
r_type: Option<Box<syn::Type>>, _r_type: Option<Box<syn::Type>>,
} }
impl LvType { impl LvType {
pub fn new(literal_name: String) -> Self { pub fn new(literal_name: String) -> Self {
Self { Self {
literal_name, literal_name,
r_type: None, _r_type: None,
} }
} }
pub fn from(r_type: Box<syn::Type>) -> Self { pub fn from(r_type: Box<syn::Type>) -> Self {
Self { Self {
literal_name: r_type.to_token_stream().to_string(), literal_name: r_type.to_token_stream().to_string(),
r_type: Some(r_type), _r_type: Some(r_type),
} }
} }

View file

@ -206,9 +206,9 @@ pub enum Part {
All, All,
} }
impl Into<u8> for Part { impl From<Part> for u8 {
fn into(self) -> u8 { fn from(self_: Part) -> u8 {
match self { match self_ {
Part::Main => lvgl_sys::LV_OBJ_PART_MAIN as u8, Part::Main => lvgl_sys::LV_OBJ_PART_MAIN as u8,
Part::All => lvgl_sys::LV_OBJ_PART_ALL as u8, Part::All => lvgl_sys::LV_OBJ_PART_ALL as u8,
} }

View file

@ -56,9 +56,9 @@ bitflags! {
} }
} }
impl Into<u8> for Opacity { impl From<Opacity> for u8 {
fn into(self) -> u8 { fn from(self_: Opacity) -> u8 {
self.bits as u8 self_.bits as u8
} }
} }

View file

@ -203,9 +203,9 @@ pub enum Align {
OutRightBottom, OutRightBottom,
} }
impl Into<u8> for Align { impl From<Align> for u8 {
fn into(self) -> u8 { fn from(self_: Align) -> u8 {
let native = match self { let native = match self_ {
Align::Center => lvgl_sys::LV_ALIGN_CENTER, Align::Center => lvgl_sys::LV_ALIGN_CENTER,
Align::InTopLeft => lvgl_sys::LV_ALIGN_IN_TOP_LEFT, Align::InTopLeft => lvgl_sys::LV_ALIGN_IN_TOP_LEFT,
Align::InTopMid => lvgl_sys::LV_ALIGN_IN_TOP_MID, Align::InTopMid => lvgl_sys::LV_ALIGN_IN_TOP_MID,

View file

@ -187,17 +187,14 @@ where
// We use iterators here to ensure that the Rust compiler can apply all possible // We use iterators here to ensure that the Rust compiler can apply all possible
// optimizations at compile time. // optimizations at compile time.
let pixels = ys let pixels = ys.enumerate().flat_map(|(iy, y)| {
.enumerate() xs.clone().map(move |(ix, x)| {
.map(|(iy, y)| { let color_len = x_len * iy + ix;
xs.clone().map(move |(ix, x)| { let lv_color = unsafe { *color_p.add(color_len) };
let color_len = x_len * iy + ix; let raw_color = Color::from_raw(lv_color);
let lv_color = unsafe { *color_p.add(color_len) }; drawable::Pixel(Point::new(x as i32, y as i32), raw_color.into())
let raw_color = Color::from_raw(lv_color);
drawable::Pixel(Point::new(x as i32, y as i32), raw_color.into())
})
}) })
.flatten(); });
Ok(display.draw_iter(pixels)?) display.draw_iter(pixels)
} }