prefer lossless conversion to cast (clippy::cast_lossless)

This commit is contained in:
Daniel Eades 2024-04-15 20:44:25 +01:00 committed by Jeremy Soller
parent e3a0d8c6dd
commit 76d166b266
3 changed files with 18 additions and 18 deletions

View file

@ -322,7 +322,7 @@ impl Config {
}
pub fn opacity_ratio(&self) -> f32 {
(self.opacity as f32) / 100.0
f32::from(self.opacity) / 100.0
}
// Get a sorted and adjusted for duplicates list of profile names and ids

View file

@ -452,9 +452,9 @@ impl App {
{
let color = Color::from(theme.cosmic().background.base);
let bytes = color.into_rgba8();
let data = (bytes[2] as u32)
| ((bytes[1] as u32) << 8)
| ((bytes[0] as u32) << 16)
let data = u32::from(bytes[2])
| (u32::from(bytes[1]) << 8)
| (u32::from(bytes[0]) << 16)
| 0xFF000000;
terminal::WINDOW_BG_COLOR.store(data, Ordering::SeqCst);
}
@ -938,8 +938,8 @@ impl App {
let padding = Padding {
top: 0.0,
bottom: 0.0,
left: space_s as f32,
right: space_s as f32,
left: space_s.into(),
right: space_s.into(),
};
profiles_section =
profiles_section.add(widget::container(expanded_section).padding(padding))

View file

@ -234,7 +234,7 @@ where
let state = tree.state.downcast_ref::<State>();
let cosmic_theme = theme.cosmic();
let scrollbar_w = cosmic_theme.spacing.space_xxs as f32;
let scrollbar_w = f32::from(cosmic_theme.spacing.space_xxs);
let view_position = layout.position() + [self.padding.left, self.padding.top].into();
let view_w = cmp::min(viewport.width as i32, layout.bounds().width as i32)
@ -271,12 +271,12 @@ where
..Default::default()
},
Color::new(
background_color.r() as f32 / 255.0,
background_color.g() as f32 / 255.0,
background_color.b() as f32 / 255.0,
f32::from(background_color.r()) / 255.0,
f32::from(background_color.g()) / 255.0,
f32::from(background_color.b()) / 255.0,
match self.opacity {
Some(opacity) => opacity,
None => background_color.a() as f32 / 255.0,
None => f32::from(background_color.a()) / 255.0,
},
),
);
@ -322,10 +322,10 @@ where
) {
let cosmic_text_to_iced_color = |color: cosmic_text::Color| {
Color::new(
color.r() as f32 / 255.0,
color.g() as f32 / 255.0,
color.b() as f32 / 255.0,
color.a() as f32 / 255.0,
f32::from(color.r()) / 255.0,
f32::from(color.g()) / 255.0,
f32::from(color.b()) / 255.0,
f32::from(color.a()) / 255.0,
)
};
@ -1050,9 +1050,9 @@ fn shade(color: cosmic_text::Color, is_focused: bool) -> cosmic_text::Color {
} else {
let shade = 0.92;
cosmic_text::Color::rgba(
(color.r() as f32 * shade) as u8,
(color.g() as f32 * shade) as u8,
(color.b() as f32 * shade) as u8,
(f32::from(color.r()) * shade) as u8,
(f32::from(color.g()) * shade) as u8,
(f32::from(color.b()) * shade) as u8,
color.a(),
)
}