Skip to content

Commit df86e2b

Browse files
authored
Merge pull request #714 from dcampbell24/fix-lints
Fix lints
2 parents 2d69fff + 854c18d commit df86e2b

File tree

14 files changed

+32
-25
lines changed

14 files changed

+32
-25
lines changed

plotters-backend/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
features, you need to play with `ensure_prepared` and `present` method. The following figure illustrates how Plotters operates a drawing backend.
2727
2828
- `ensure_prepared` - Called before each time when plotters want to draw. This function should initialize the backend for current frame, if the backend is already prepared
29-
for a frame, this function should simply do nothing.
29+
for a frame, this function should simply do nothing.
3030
- `present` - Called when plotters want to finish current frame drawing
3131
3232

plotters-backend/src/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub trait BackendTextStyle {
217217
text_anchor::Pos::default()
218218
}
219219

220-
fn family(&self) -> FontFamily;
220+
fn family(&self) -> FontFamily<'_>;
221221

222222
#[allow(clippy::type_complexity)]
223223
fn layout_box(&self, text: &str) -> Result<((i32, i32), (i32, i32)), Self::FontError>;

plotters-bitmap/src/bitmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'a, P: PixelFormat> BitMapBackend<'a, P> {
142142
///
143143
/// - `area_size`: The size of the area
144144
/// - **returns**: The split backends that can be rendered in parallel
145-
pub fn split(&mut self, area_size: &[u32]) -> Vec<BitMapBackend<P>> {
145+
pub fn split(&mut self, area_size: &[u32]) -> Vec<BitMapBackend<'_, P>> {
146146
let (w, h) = self.get_size();
147147
let buf = self.get_raw_pixel_buffer();
148148

plotters-bitmap/src/bitmap_pixel/bgrx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl PixelFormat for BGRXPixel {
193193
// TODO: Consider using AVX instructions when possible
194194
let ptr = p as *mut [u8; 8] as *mut u64;
195195
unsafe {
196-
let d: u64 = std::mem::transmute([
196+
let d: u64 = u64::from_ne_bytes([
197197
b, g, r, 0, b, g, r, 0, // QW1
198198
]);
199199
ptr.write_unaligned(d);

plotters/src/chart/context/cartesian3d/draw_impl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ where
114114
}
115115
Ok(())
116116
}
117+
118+
#[allow(clippy::needless_range_loop)]
117119
#[allow(clippy::type_complexity)]
118120
pub(crate) fn draw_axis(
119121
&mut self,

plotters/src/coord/ranged1d/combinators/group_by.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<T: AsRangedCoord + Sized> ToGroupByRange for T where T::CoordDescType: Disc
4545

4646
impl<T: DiscreteRanged> DiscreteRanged for GroupBy<T> {
4747
fn size(&self) -> usize {
48-
(self.0.size() + self.1 - 1) / self.1
48+
self.0.size().div_ceil(self.1)
4949
}
5050
fn index_of(&self, value: &Self::ValueType) -> Option<usize> {
5151
self.0.index_of(value).map(|idx| idx / self.1)
@@ -75,8 +75,9 @@ impl<T: DiscreteRanged> Ranged for GroupBy<T> {
7575
let range = 0..(self.0.size() + self.1) / self.1;
7676
//let logic_range: RangedCoordusize = range.into();
7777

78-
let interval =
79-
((range.end - range.start + hint.bold_points() - 1) / hint.bold_points()).max(1);
78+
let interval = (range.end - range.start)
79+
.div_ceil(hint.bold_points())
80+
.max(1);
8081
let count = (range.end - range.start) / interval;
8182

8283
let idx_iter = (0..hint.bold_points()).map(|x| x * interval);
@@ -85,7 +86,7 @@ impl<T: DiscreteRanged> Ranged for GroupBy<T> {
8586
let outer_ticks = idx_iter;
8687
let outer_tick_size = interval * self.1;
8788
let inner_ticks_per_group = hint.max_num_points() / outer_ticks.len();
88-
let inner_ticks = (outer_tick_size + inner_ticks_per_group - 1) / inner_ticks_per_group;
89+
let inner_ticks = outer_tick_size.div_ceil(inner_ticks_per_group);
8990
let inner_ticks: Vec<_> = (0..(outer_tick_size / inner_ticks))
9091
.map(move |x| x * inner_ticks)
9192
.collect();

plotters/src/coord/ranged1d/types/datetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ impl Ranged for RangedDuration {
769769
if let Some(period) = compute_period_per_point(total_ns as u64, max_points, false) {
770770
let mut start_ns = self.0.num_nanoseconds().unwrap();
771771

772-
if start_ns as u64 % period > 0 {
772+
if !(start_ns as u64).is_multiple_of(period) {
773773
if start_ns > 0 {
774774
start_ns += period as i64 - (start_ns % period as i64);
775775
} else {

plotters/src/coord/ranged1d/types/numeric.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
use std::convert::TryFrom;
22
use std::ops::Range;
33

4-
use crate::coord::{combinators::WithKeyPoints, ranged1d::{
5-
AsRangedCoord, DefaultFormatting, DiscreteRanged, KeyPointHint, NoDefaultFormatting, Ranged,
6-
ReversibleRanged, ValueFormatter,
7-
}};
4+
use crate::coord::{
5+
combinators::WithKeyPoints,
6+
ranged1d::{
7+
AsRangedCoord, DefaultFormatting, DiscreteRanged, KeyPointHint, NoDefaultFormatting,
8+
Ranged, ReversibleRanged, ValueFormatter,
9+
},
10+
};
811

912
macro_rules! impl_discrete_trait {
1013
($name:ident) => {

plotters/src/element/image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'a, Coord, P: PixelFormat> BitMapElement<'a, Coord, P> {
147147
/// Copy the existing bitmap element to another location
148148
///
149149
/// - `pos`: The new location to copy
150-
pub fn copy_to<Coord2>(&self, pos: Coord2) -> BitMapElement<Coord2, P> {
150+
pub fn copy_to<Coord2>(&self, pos: Coord2) -> BitMapElement<'_, Coord2, P> {
151151
BitMapElement {
152152
image: Buffer::Borrowed(self.image.borrow()),
153153
size: self.size,
@@ -165,7 +165,7 @@ impl<'a, Coord, P: PixelFormat> BitMapElement<'a, Coord, P> {
165165

166166
/// Make the bitmap element as a bitmap backend, so that we can use
167167
/// plotters drawing functionality on the bitmap element
168-
pub fn as_bitmap_backend(&mut self) -> BitMapBackend<P> {
168+
pub fn as_bitmap_backend(&mut self) -> BitMapBackend<'_, P> {
169169
BitMapBackend::with_buffer_and_format(self.image.to_mut(), self.size).unwrap()
170170
}
171171
}

plotters/src/element/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn layout_multiline_text<'a, F: FnMut(&'a str)>(
148148

149149
let end_idx = match indices.peek() {
150150
Some(idx) => *idx,
151-
None => line.bytes().len(),
151+
None => line.len(),
152152
};
153153

154154
Some(&line[start_idx..end_idx])

0 commit comments

Comments
 (0)