1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

style(core/rust): clippy hints applied

[no changelog]
This commit is contained in:
matejcik 2024-05-17 12:18:34 +02:00 committed by matejcik
parent 754b0a92b9
commit ad84f42b0b
4 changed files with 20 additions and 19 deletions

View File

@ -66,8 +66,8 @@ impl ffi::gfx_bitblt_t {
/// # SAFETY /// # SAFETY
/// 1) Ensure that the rectangle is completely inside the destination /// 1) Ensure that the rectangle is completely inside the destination
/// bitmap. /// bitmap.
/// 2) If the copy or blend operation is used, ensure that the rectangle /// 2) If the copy or blend operation is used, ensure that the rectangle is
/// is completely filled with source bitmap or its part. /// completely filled with source bitmap or its part.
unsafe fn with_rect(self, r: Rect) -> Self { unsafe fn with_rect(self, r: Rect) -> Self {
Self { Self {
width: r.width() as u16, width: r.width() as u16,

View File

@ -512,7 +512,7 @@ extern "C" fn new_confirm_joint_total(n_args: usize, args: *const Obj, kwargs: *
]); ]);
content_in_button_page( content_in_button_page(
TR::joint__title.try_into()?, TR::joint__title.into(),
paragraphs, paragraphs,
TR::buttons__hold_to_confirm.into(), TR::buttons__hold_to_confirm.into(),
Some("".into()), Some("".into()),
@ -542,7 +542,7 @@ extern "C" fn new_confirm_modify_output(n_args: usize, args: *const Obj, kwargs:
]); ]);
content_in_button_page( content_in_button_page(
TR::modify_amount__title.try_into()?, TR::modify_amount__title.into(),
paragraphs, paragraphs,
TR::buttons__confirm.into(), TR::buttons__confirm.into(),
Some("".into()), Some("".into()),
@ -914,7 +914,7 @@ extern "C" fn new_confirm_modify_fee(n_args: usize, args: *const Obj, kwargs: *m
} }
content_in_button_page( content_in_button_page(
TR::modify_fee__title.try_into()?, TR::modify_fee__title.into(),
paragraphs_vec.into_paragraphs(), paragraphs_vec.into_paragraphs(),
TR::buttons__confirm.into(), TR::buttons__confirm.into(),
Some("".into()), Some("".into()),
@ -1099,7 +1099,7 @@ extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) -
extern "C" fn new_show_passphrase() -> Obj { extern "C" fn new_show_passphrase() -> Obj {
let block = move || { let block = move || {
let text: TString = TR::passphrase__please_enter.try_into()?; let text: TString = TR::passphrase__please_enter.into();
let paragraph = Paragraph::new(&theme::TEXT_NORMAL, text).centered(); let paragraph = Paragraph::new(&theme::TEXT_NORMAL, text).centered();
let content = Paragraphs::new([paragraph]); let content = Paragraphs::new([paragraph]);
let obj = LayoutObj::new(content)?; let obj = LayoutObj::new(content)?;
@ -1223,7 +1223,7 @@ extern "C" fn new_confirm_coinjoin(n_args: usize, args: *const Obj, kwargs: *mut
]); ]);
content_in_button_page( content_in_button_page(
TR::coinjoin__title.try_into()?, TR::coinjoin__title.into(),
paragraphs, paragraphs,
TR::buttons__hold_to_confirm.into(), TR::buttons__hold_to_confirm.into(),
None, None,
@ -1418,7 +1418,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
}; };
content_in_button_page( content_in_button_page(
title.try_into()?, title.into(),
paragraphs.into_paragraphs(), paragraphs.into_paragraphs(),
button, button,
Some("".into()), Some("".into()),
@ -1430,7 +1430,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = |_args: &[Obj], _kwargs: &Map| { let block = |_args: &[Obj], _kwargs: &Map| {
let title: TString = TR::word_count__title.try_into()?; let title: TString = TR::word_count__title.into();
let choices: Vec<TString<'static>, 5> = ["12", "18", "20", "24", "33"] let choices: Vec<TString<'static>, 5> = ["12", "18", "20", "24", "33"]
.map(|num| num.into()) .map(|num| num.into())

View File

@ -7,7 +7,6 @@ use crate::{
component::{Component, Event, EventCtx, Pad}, component::{Component, Event, EventCtx, Pad},
display::{self, toif::Icon, Color}, display::{self, toif::Icon, Color},
geometry::{Alignment2D, Offset, Rect}, geometry::{Alignment2D, Offset, Rect},
lerp::Lerp,
model_tt::constant, model_tt::constant,
shape::{self, Renderer}, shape::{self, Renderer},
util::animation_disabled, util::animation_disabled,
@ -180,6 +179,8 @@ impl Component for Loader {
} else { } else {
#[cfg(feature = "haptic")] #[cfg(feature = "haptic")]
{ {
use crate::ui::lerp::Lerp;
if matches!(self.state, State::Growing(_)) { if matches!(self.state, State::Growing(_)) {
let progress = let progress =
self.progress(now).unwrap() as f32 / display::LOADER_MAX as f32; self.progress(now).unwrap() as f32 / display::LOADER_MAX as f32;

View File

@ -549,7 +549,7 @@ extern "C" fn new_confirm_address(n_args: usize, args: *const Obj, kwargs: *mut
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let description: Option<TString> = let description: Option<TString> =
kwargs.get(Qstr::MP_QSTR_description)?.try_into_option()?; kwargs.get(Qstr::MP_QSTR_description)?.try_into_option()?;
let verb: TString = kwargs.get_or(Qstr::MP_QSTR_verb, TR::buttons__confirm.try_into()?)?; let verb: TString = kwargs.get_or(Qstr::MP_QSTR_verb, TR::buttons__confirm.into())?;
let extra: Option<TString> = kwargs.get(Qstr::MP_QSTR_extra)?.try_into_option()?; let extra: Option<TString> = kwargs.get(Qstr::MP_QSTR_extra)?.try_into_option()?;
let data: Obj = kwargs.get(Qstr::MP_QSTR_data)?; let data: Obj = kwargs.get(Qstr::MP_QSTR_data)?;
let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, false)?; let chunkify: bool = kwargs.get_or(Qstr::MP_QSTR_chunkify, false)?;
@ -887,7 +887,7 @@ fn new_show_modal(
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?; let value: TString = kwargs.get_or(Qstr::MP_QSTR_value, "".into())?;
let description: TString = kwargs.get_or(Qstr::MP_QSTR_description, "".into())?; let description: TString = kwargs.get_or(Qstr::MP_QSTR_description, "".into())?;
let button: TString = kwargs.get_or(Qstr::MP_QSTR_button, TR::buttons__continue.try_into()?)?; let button: TString = kwargs.get_or(Qstr::MP_QSTR_button, TR::buttons__continue.into())?;
let allow_cancel: bool = kwargs.get_or(Qstr::MP_QSTR_allow_cancel, true)?; let allow_cancel: bool = kwargs.get_or(Qstr::MP_QSTR_allow_cancel, true)?;
let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?; let time_ms: u32 = kwargs.get_or(Qstr::MP_QSTR_time_ms, 0)?;
@ -1038,9 +1038,9 @@ extern "C" fn new_show_info(n_args: usize, args: *const Obj, kwargs: *mut Map) -
extern "C" fn new_show_mismatch(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { extern "C" fn new_show_mismatch(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| { let block = move |_args: &[Obj], kwargs: &Map| {
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let description: TString = TR::addr_mismatch__contact_support_at.try_into()?; let description: TString = TR::addr_mismatch__contact_support_at.into();
let url: TString = TR::addr_mismatch__support_url.try_into()?; let url: TString = TR::addr_mismatch__support_url.into();
let button: TString = TR::buttons__quit.try_into()?; let button: TString = TR::buttons__quit.into();
let icon = BlendedImage::new( let icon = BlendedImage::new(
theme::IMAGE_BG_OCTAGON, theme::IMAGE_BG_OCTAGON,
@ -1387,9 +1387,9 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
.with_spacing(theme::RECOVERY_SPACING); .with_spacing(theme::RECOVERY_SPACING);
let notification: TString = if dry_run { let notification: TString = if dry_run {
TR::recovery__title_dry_run.try_into()? TR::recovery__title_dry_run.into()
} else { } else {
TR::recovery__title.try_into()? TR::recovery__title.into()
}; };
let obj = if info_button { let obj = if info_button {
@ -1420,9 +1420,9 @@ extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mu
let block = move |_args: &[Obj], kwargs: &Map| { let block = move |_args: &[Obj], kwargs: &Map| {
let dry_run: bool = kwargs.get(Qstr::MP_QSTR_dry_run)?.try_into()?; let dry_run: bool = kwargs.get(Qstr::MP_QSTR_dry_run)?.try_into()?;
let title: TString = if dry_run { let title: TString = if dry_run {
TR::recovery__title_dry_run.try_into()? TR::recovery__title_dry_run.into()
} else { } else {
TR::recovery__title.try_into()? TR::recovery__title.into()
}; };
let paragraphs = Paragraphs::new(Paragraph::new( let paragraphs = Paragraphs::new(Paragraph::new(