Skip to content

Commit aed91f1

Browse files
committed
A couple more cleanups before cargo publish.
1 parent 4de40e8 commit aed91f1

File tree

6 files changed

+44
-33
lines changed

6 files changed

+44
-33
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ stronghold = {version = "0.2", optional = true} # file
3434
serde = {version = "1.0", optional = true}
3535
stick = {version = "0.7", optional = true} # joystick / controller
3636
# barg = {version = "0.2", optional = true} # video
37-
window = {optional = true, path = "../window"}
38-
fonterator = {version = "0.5", optional = true, default-features = false, features = ["normal-font"]}
37+
window = {version = "0.3", optional = true}
38+
fonterator = {version = "0.6", optional = true, default-features = false, features = ["normal-font"]}
3939
rvg = {version = "0.0.2", optional = true, features = ["footile"]}
4040
chrono = {version = "0.4", optional = true} # clock
4141

changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ and this project adheres to [Semantic Versioning](https://code.plopgrizzly.com/s
88
### TODO
99
- Possibly redesign the controller API to be event based using a message queue.
1010

11-
## [0.6.0] - 2019-10-24
11+
## [0.6.0] - 2019-10-25
1212
### Added
1313
- `aspect()` for getting aspect ratio
1414

1515
### Fixed
16-
- Some warnings
16+
- All of warnings, including clippy warnings
1717

1818
### Changed
1919
- Replaced instances with groups.

src/clock.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ impl Duration {
4444
impl Div<i32> for Duration {
4545
type Output = Duration;
4646

47+
// This is a fraction, so multiplication is in fact the machine operation to
48+
// use, even though it's the division operator.
49+
#[allow(clippy::suspicious_arithmetic_impl)]
4750
fn div(mut self, mut other: i32) -> Self::Output {
4851
if other.is_negative() {
4952
self.seconds = -self.seconds;
@@ -171,8 +174,8 @@ impl Clock {
171174
sec: u8,
172175
) -> Option<Self> {
173176
let date = chrono::offset::Utc
174-
.ymd(year, month as u32, day as u32)
175-
.and_hms(hour as u32, min as u32, sec as u32);
177+
.ymd(year, u32::from(month), u32::from(day))
178+
.and_hms(u32::from(hour), u32::from(min), u32::from(sec));
176179

177180
Some(Clock(date.naive_utc()))
178181
}
@@ -191,8 +194,8 @@ impl Clock {
191194
sec: u8,
192195
) -> Option<Self> {
193196
let date = chrono::offset::Local
194-
.ymd(year, month as u32, day as u32)
195-
.and_hms(hour as u32, min as u32, sec as u32)
197+
.ymd(year, u32::from(month), u32::from(day))
198+
.and_hms(u32::from(hour), u32::from(min), u32::from(sec))
196199
.with_timezone(&chrono::Utc);
197200

198201
Some(Clock(date.naive_utc()))
@@ -256,10 +259,10 @@ impl Clock {
256259
.unwrap();
257260

258261
// Multiply time by reciprocal fraction (numerator).
259-
let frac_den = frac.denominator as i128;
260-
let frac_num = frac.seconds as i128;
261-
let seconds = seconds as i128 * frac_num;
262-
let nanos = nanos as i128 * frac_num;
262+
let frac_den = i128::from(frac.denominator);
263+
let frac_num = i128::from(frac.seconds);
264+
let seconds = i128::from(seconds) * frac_num;
265+
let nanos = i128::from(nanos) * frac_num;
263266

264267
// Denominator
265268
let seconds_remaining = seconds % frac_den; // what couldn't be divided
@@ -272,6 +275,12 @@ impl Clock {
272275
}
273276
}
274277

278+
impl Default for Clock {
279+
fn default() -> Self {
280+
Self::new()
281+
}
282+
}
283+
275284
impl Debug for Clock {
276285
fn fmt(&self, f: &mut Formatter) -> Result {
277286
write!(f, "{}", self.0)

src/icons.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
use fonterator::footile;
44
use rvg::*;
55

6-
const BACK: &'static [u8] = include_bytes!("../rvg/back.svg.rvg");
7-
const EXIT: &'static [u8] = include_bytes!("../rvg/exit.svg.rvg");
8-
const FULLSCREEN: &'static [u8] = include_bytes!("../rvg/fullscreen.svg.rvg");
9-
const GRID: &'static [u8] = include_bytes!("../rvg/grid.svg.rvg");
10-
const HIDE: &'static [u8] = include_bytes!("../rvg/hide.svg.rvg");
11-
const MENU: &'static [u8] = include_bytes!("../rvg/menu.svg.rvg");
12-
const MORE: &'static [u8] = include_bytes!("../rvg/more.svg.rvg");
13-
const NEW: &'static [u8] = include_bytes!("../rvg/new.svg.rvg");
14-
const NEXT: &'static [u8] = include_bytes!("../rvg/next.svg.rvg");
15-
const SEARCH: &'static [u8] = include_bytes!("../rvg/search.svg.rvg");
16-
const VIEW: &'static [u8] = include_bytes!("../rvg/view.svg.rvg");
17-
const ZOOM_IN: &'static [u8] = include_bytes!("../rvg/zoom_in.svg.rvg");
18-
const ZOOM_OUT: &'static [u8] = include_bytes!("../rvg/zoom_out.svg.rvg");
6+
const BACK: &[u8] = include_bytes!("../rvg/back.svg.rvg");
7+
const EXIT: &[u8] = include_bytes!("../rvg/exit.svg.rvg");
8+
const FULLSCREEN: &[u8] = include_bytes!("../rvg/fullscreen.svg.rvg");
9+
const GRID: &[u8] = include_bytes!("../rvg/grid.svg.rvg");
10+
const HIDE: &[u8] = include_bytes!("../rvg/hide.svg.rvg");
11+
const MENU: &[u8] = include_bytes!("../rvg/menu.svg.rvg");
12+
const MORE: &[u8] = include_bytes!("../rvg/more.svg.rvg");
13+
const NEW: &[u8] = include_bytes!("../rvg/new.svg.rvg");
14+
const NEXT: &[u8] = include_bytes!("../rvg/next.svg.rvg");
15+
const SEARCH: &[u8] = include_bytes!("../rvg/search.svg.rvg");
16+
const VIEW: &[u8] = include_bytes!("../rvg/view.svg.rvg");
17+
const ZOOM_IN: &[u8] = include_bytes!("../rvg/zoom_in.svg.rvg");
18+
const ZOOM_OUT: &[u8] = include_bytes!("../rvg/zoom_out.svg.rvg");
1919

2020
pub fn text(
2121
pixels: &mut [footile::Rgba8],
@@ -27,13 +27,14 @@ pub fn text(
2727
let graphic_h = graphic_h / 2;
2828

2929
// Render
30-
let mut p = footile::Plotter::new(width as u32, graphic_h as u32 * 2);
30+
let mut p =
31+
footile::Plotter::new(u32::from(width), u32::from(graphic_h) * 2);
3132
let r = footile::RasterB::new(p.width(), p.height());
3233
let path: Vec<_> = font
3334
.render(
34-
text, /*text*/
35-
(0.0, 0.0, width as f32, graphic_h as f32), /*bbox*/
36-
(graphic_h as f32, graphic_h as f32), /*size*/
35+
text, /*text*/
36+
(0.0, 0.0, f32::from(width), f32::from(graphic_h)), /*bbox*/
37+
(f32::from(graphic_h), f32::from(graphic_h)), /*size*/
3738
fonterator::TextAlign::Center,
3839
)
3940
.0
@@ -44,7 +45,7 @@ pub fn text(
4445
unsafe {
4546
std::slice::from_raw_parts_mut(
4647
pixels.as_mut_ptr(),
47-
width as usize * graphic_h as usize * 2,
48+
usize::from(width) * usize::from(graphic_h) * 2,
4849
)
4950
},
5051
);
@@ -62,7 +63,7 @@ fn half(
6263
let ad = (graphic_h / 2) - (margin);
6364

6465
let offs = if x > 6 {
65-
x = x - 6;
66+
x -= 6;
6667
width - (8 * ad)
6768
} else {
6869
0
@@ -82,7 +83,7 @@ fn full(
8283
let ad = (graphic_h / 2) - (margin);
8384

8485
let offs = if x > 6 {
85-
x = x - 6;
86+
x -= 6;
8687
width - (8 * ad)
8788
} else {
8889
0

src/internal/barg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Shader {
7171
fn toolbar(buffer: &mut [u8], width: u16) {
7272
let height = buffer.len() / (4 * width as usize);
7373
let size = (width, height as u16);
74-
let mut p = fonterator::footile::Plotter::new(size.0 as u32, size.1 as u32);
74+
let mut p = fonterator::footile::Plotter::new(u32::from(size.0), u32::from(size.1));
7575
let image = fonterator::footile::RasterB::new(p.width(), p.height());
7676

7777
use fonterator::PathOp::*;

src/timer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct TimedLoop {
99

1010
impl TimedLoop {
1111
/// Seconds and nanoseconds (1 / 1_000_000_000 of a second).
12+
#[allow(clippy::cast_lossless)] // const fn doesn't support u64::from() yet
1213
pub const fn new(secs: u32, nanos: u32) -> TimedLoop {
1314
let whol = secs as u64 * 1_000_000_000u64;
1415
let frac = nanos as u64;

0 commit comments

Comments
 (0)