From f358ad05fc515974262ea7f4cf8f1b6a4ef77054 Mon Sep 17 00:00:00 2001 From: Nia Espera Date: Tue, 20 Jun 2023 18:46:25 +0200 Subject: [PATCH] fmt --- lvgl/src/display.rs | 23 +++++++++++++---------- lvgl/src/functions.rs | 5 ++++- lvgl/src/lv_core/obj.rs | 14 +++++++++++--- lvgl/src/lv_core/screen.rs | 2 +- lvgl/src/support.rs | 20 ++++++++++++-------- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/lvgl/src/display.rs b/lvgl/src/display.rs index c5f3d19f..5ba7aee5 100644 --- a/lvgl/src/display.rs +++ b/lvgl/src/display.rs @@ -3,13 +3,13 @@ use crate::Screen; use crate::{disp_drv_register, disp_get_default, get_str_act, LvResult, NativeObject}; use crate::{Box, Color}; use core::convert::TryInto; +#[cfg(feature = "nightly")] +use core::error::Error; +use core::fmt; use core::mem::{ManuallyDrop, MaybeUninit}; use core::pin::Pin; use core::ptr::NonNull; use core::{ptr, result}; -use core::fmt; -#[cfg(feature = "nightly")] -use core::error::Error; /// Error in interacting with a `Display`. #[derive(Debug, Copy, Clone, Eq, PartialEq)] @@ -21,11 +21,15 @@ pub enum DisplayError { impl fmt::Display for DisplayError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Display {}", match self { - DisplayError::NotAvailable => "not available", - DisplayError::FailedToRegister => "failed to register", - DisplayError::NotRegistered => "not registered", - }) + write!( + f, + "Display {}", + match self { + DisplayError::NotAvailable => "not available", + DisplayError::FailedToRegister => "failed to register", + DisplayError::NotRegistered => "not registered", + } + ) } } @@ -396,8 +400,7 @@ mod tests { let _screen_direct = display .get_scr_act() .expect("Return screen directly from the display instance"); - let _screen_default = - get_scr_act().expect("Return screen from the default display"); + let _screen_default = get_scr_act().expect("Return screen from the default display"); } #[test] diff --git a/lvgl/src/functions.rs b/lvgl/src/functions.rs index 3b1eddad..b99c7734 100644 --- a/lvgl/src/functions.rs +++ b/lvgl/src/functions.rs @@ -69,7 +69,10 @@ pub fn task_handler() { /// Directly send an event to a specific widget. #[inline] -pub fn event_send Widget<'a>>(obj: &mut W, event: Event<>::SpecialEvent>) -> LvResult<()> { +pub fn event_send Widget<'a>>( + obj: &mut W, + event: Event<>::SpecialEvent>, +) -> LvResult<()> { unsafe { lvgl_sys::lv_event_send(obj.raw()?.as_mut(), event.into(), ptr::null_mut()); }; diff --git a/lvgl/src/lv_core/obj.rs b/lvgl/src/lv_core/obj.rs index c44aba1d..26797e87 100644 --- a/lvgl/src/lv_core/obj.rs +++ b/lvgl/src/lv_core/obj.rs @@ -44,7 +44,10 @@ impl Obj<'_> { let ptr = lvgl_sys::lv_obj_create(parent.raw()?.as_mut()); if ptr::NonNull::new(ptr).is_some() { //(*ptr).user_data = Box::new(UserDataObj::empty()).into_raw() as *mut _; - Ok(Self { raw: ptr, styles_used: PhantomData }) + Ok(Self { + raw: ptr, + styles_used: PhantomData, + }) } else { Err(LvError::InvalidReference) } @@ -152,7 +155,10 @@ impl<'a> Widget<'a> for Obj<'a> { type Part = Part; unsafe fn from_raw(raw: ptr::NonNull) -> Option { - Some(Self { raw: raw.as_ptr(), styles_used: PhantomData }) + Some(Self { + raw: raw.as_ptr(), + styles_used: PhantomData, + }) } } @@ -195,7 +201,9 @@ macro_rules! define_object { obj.user_data = $crate::Box::into_raw($crate::Box::new(f)) as *mut _; lvgl_sys::lv_obj_add_event_cb( obj, - lvgl_sys::lv_event_cb_t::Some($crate::support::event_callback::<'a, Self, F>), + lvgl_sys::lv_event_cb_t::Some( + $crate::support::event_callback::<'a, Self, F>, + ), lvgl_sys::lv_event_code_t_LV_EVENT_ALL, obj.user_data, ); diff --git a/lvgl/src/lv_core/screen.rs b/lvgl/src/lv_core/screen.rs index 4769e5fe..40fd5670 100644 --- a/lvgl/src/lv_core/screen.rs +++ b/lvgl/src/lv_core/screen.rs @@ -37,7 +37,7 @@ impl<'a> TryFrom> for Screen<'a> { fn try_from(value: Obj<'a>) -> Result { match unsafe { (*value.raw()?.as_mut()).parent } as usize { - 0 => Ok(Self { raw: value, }), + 0 => Ok(Self { raw: value }), _ => Err(LvError::InvalidReference), } } diff --git a/lvgl/src/support.rs b/lvgl/src/support.rs index aa24d9e1..358f58e7 100644 --- a/lvgl/src/support.rs +++ b/lvgl/src/support.rs @@ -1,10 +1,10 @@ use crate::display::DisplayError; use crate::Widget; use core::convert::{TryFrom, TryInto}; -use core::ptr::NonNull; -use core::fmt; #[cfg(feature = "nightly")] use core::error::Error; +use core::fmt; +use core::ptr::NonNull; #[cfg(feature = "embedded_graphics")] use embedded_graphics::pixelcolor::{Rgb565, Rgb888}; @@ -21,12 +21,16 @@ pub enum LvError { impl fmt::Display for LvError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", match self { - LvError::InvalidReference => "Accessed invalid reference or ptr", - LvError::Uninitialized => "LVGL uninitialized", - LvError::LvOOMemory => "LVGL out of memory", - LvError::AlreadyInUse => "Resource already in use", - }) + write!( + f, + "{}", + match self { + LvError::InvalidReference => "Accessed invalid reference or ptr", + LvError::Uninitialized => "LVGL uninitialized", + LvError::LvOOMemory => "LVGL out of memory", + LvError::AlreadyInUse => "Resource already in use", + } + ) } }