diff --git a/plotters-backend/src/rasterizer/polygon.rs b/plotters-backend/src/rasterizer/polygon.rs index ce33c5cf..a91baf53 100644 --- a/plotters-backend/src/rasterizer/polygon.rs +++ b/plotters-backend/src/rasterizer/polygon.rs @@ -49,7 +49,7 @@ impl Edge { impl PartialOrd for Edge { fn partial_cmp(&self, other: &Self) -> Option { - self.get_slave_pos().partial_cmp(&other.get_slave_pos()) + Some(self.cmp(other)) } } diff --git a/plotters-bitmap/src/bitmap_pixel/bgrx.rs b/plotters-bitmap/src/bitmap_pixel/bgrx.rs index 2f90d9d5..fe97f4da 100644 --- a/plotters-bitmap/src/bitmap_pixel/bgrx.rs +++ b/plotters-bitmap/src/bitmap_pixel/bgrx.rs @@ -36,7 +36,7 @@ impl PixelFormat for BGRXPixel { a: f64, ) { let (w, h) = target.get_size(); - let a = a.min(1.0).max(0.0); + let a = a.clamp(0.0, 1.0); if a == 0.0 { return; } diff --git a/plotters-bitmap/src/bitmap_pixel/rgb.rs b/plotters-bitmap/src/bitmap_pixel/rgb.rs index 39b3f502..1200cc09 100644 --- a/plotters-bitmap/src/bitmap_pixel/rgb.rs +++ b/plotters-bitmap/src/bitmap_pixel/rgb.rs @@ -40,7 +40,7 @@ impl PixelFormat for RGBPixel { a: f64, ) { let (w, h) = target.get_size(); - let a = a.min(1.0).max(0.0); + let a = a.clamp(0.0, 1.0); if a == 0.0 { return; } diff --git a/plotters-svg/src/svg.rs b/plotters-svg/src/svg.rs index 6557fb04..ec549f8f 100644 --- a/plotters-svg/src/svg.rs +++ b/plotters-svg/src/svg.rs @@ -27,11 +27,6 @@ fn make_svg_opacity(color: BackendColor) -> String { enum Target<'a> { File(String, &'a Path), Buffer(&'a mut String), - // TODO: At this point we won't make the breaking change - // so the u8 buffer is still supported. But in 0.3, we definitely - // should get rid of this. - #[cfg(feature = "deprecated_items")] - U8Buffer(String, &'a mut Vec), } impl Target<'_> { @@ -39,8 +34,6 @@ impl Target<'_> { match self { Target::File(ref mut buf, _) => buf, Target::Buffer(buf) => buf, - #[cfg(feature = "deprecated_items")] - Target::U8Buffer(ref mut buf, _) => buf, } } } @@ -147,24 +140,6 @@ impl<'a> SVGBackend<'a> { ret } - /// Create a new SVG drawing backend and store the document into a u8 vector - #[cfg(feature = "deprecated_items")] - #[deprecated( - note = "This will be replaced by `with_string`, consider use `with_string` to avoid breaking change in the future" - )] - pub fn with_buffer(buf: &'a mut Vec, size: (u32, u32)) -> Self { - let mut ret = Self { - target: Target::U8Buffer(String::default(), buf), - size, - tag_stack: vec![], - saved: false, - }; - - ret.init_svg_file(size); - - ret - } - /// Create a new SVG drawing backend and store the document into a String buffer pub fn with_string(buf: &'a mut String, size: (u32, u32)) -> Self { let mut ret = Self { @@ -203,11 +178,6 @@ impl<'a> DrawingBackend for SVGBackend<'a> { .map_err(DrawingErrorKind::DrawingError)?; } Target::Buffer(_) => {} - #[cfg(feature = "deprecated_items")] - Target::U8Buffer(ref actual, ref mut target) => { - target.clear(); - target.extend_from_slice(actual.as_bytes()); - } } self.saved = true; } @@ -481,11 +451,11 @@ impl<'a> DrawingBackend for SVGBackend<'a> { } #[cfg(all(not(target_arch = "wasm32"), feature = "image"))] - fn blit_bitmap<'b>( + fn blit_bitmap( &mut self, pos: BackendCoord, (w, h): (u32, u32), - src: &'b [u8], + src: &[u8], ) -> Result<(), DrawingErrorKind> { use image::codecs::png::PngEncoder; use image::ImageEncoder; @@ -508,9 +478,7 @@ impl<'a> DrawingBackend for SVGBackend<'a> { } let padding = (3 - data.len() % 3) % 3; - for _ in 0..padding { - data.push(0); - } + data.resize(data.len() + padding, 0); let mut rem_bits = 0; let mut rem_num = 0; diff --git a/plotters/Cargo.toml b/plotters/Cargo.toml index 9226f3c1..aae107e4 100644 --- a/plotters/Cargo.toml +++ b/plotters/Cargo.toml @@ -4,6 +4,7 @@ version = "0.3.6" authors = ["Hao Hou "] edition = "2018" license = "MIT" +msrv = "1.56" description = "A Rust drawing library focus on data plotting for both WASM and native applications" repository = "https://github.com/plotters-rs/plotters" homepage = "https://plotters-rs.github.io/" @@ -12,6 +13,10 @@ categories = ["visualization", "wasm"] readme = "../README.md" exclude = ["doc-template", "plotters-doc-data"] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] } +deprecated = { level = "allow" } + [dependencies] num-traits = "0.2.14" chrono = { version = "0.4.32", optional = true } diff --git a/plotters/clippy.toml b/plotters/clippy.toml deleted file mode 100644 index 17852009..00000000 --- a/plotters/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -msrv = "1.56" \ No newline at end of file diff --git a/plotters/examples/3d-plot.rs b/plotters/examples/3d-plot.rs index a5b3d068..7bfc6c3e 100644 --- a/plotters/examples/3d-plot.rs +++ b/plotters/examples/3d-plot.rs @@ -9,7 +9,7 @@ fn main() -> Result<(), Box> { let z_axis = (-3.0..3.0).step(0.1); let mut chart = ChartBuilder::on(&area) - .caption("3D Plot Test".to_string(), ("sans", 20)) + .caption("3D Plot Test", ("sans", 20)) .build_cartesian_3d(x_axis.clone(), -3.0..3.0, z_axis.clone())?; chart.with_projection(|mut pb| { diff --git a/plotters/examples/matshow.rs b/plotters/examples/matshow.rs index 967af360..09ce561c 100644 --- a/plotters/examples/matshow.rs +++ b/plotters/examples/matshow.rs @@ -11,7 +11,7 @@ fn main() -> Result<(), Box> { .margin(5) .top_x_label_area_size(40) .y_label_area_size(40) - .build_cartesian_2d(0i32..15i32, 15i32..0i32)?; + .build_cartesian_2d(0i32..15i32, 0i32..15i32)?; chart .configure_mesh() diff --git a/plotters/src/chart/builder.rs b/plotters/src/chart/builder.rs index 7f087b6c..41a4309b 100644 --- a/plotters/src/chart/builder.rs +++ b/plotters/src/chart/builder.rs @@ -194,7 +194,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartBuilder<'a, 'b, DB> { Sets the size of the X label area at the bottom of the chart. - `size`: The desired size of the X label area in backend units (pixels). - If set to 0, the X label area is removed. + If set to 0, the X label area is removed. See [`ChartBuilder::on()`] for more information and examples. */ @@ -206,7 +206,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartBuilder<'a, 'b, DB> { Sets the size of the Y label area to the left of the chart. - `size`: The desired size of the Y label area in backend units (pixels). - If set to 0, the Y label area is removed. + If set to 0, the Y label area is removed. See [`ChartBuilder::on()`] for more information and examples. */ @@ -218,7 +218,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartBuilder<'a, 'b, DB> { Sets the size of the X label area at the top of the chart. - `size`: The desired size of the top X label area in backend units (pixels). - If set to 0, the top X label area is removed. + If set to 0, the top X label area is removed. See [`ChartBuilder::on()`] for more information and examples. */ @@ -230,7 +230,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartBuilder<'a, 'b, DB> { Sets the size of the Y label area to the right of the chart. - `size`: The desired size of the Y label area in backend units (pixels). - If set to 0, the Y label area to the right is removed. + If set to 0, the Y label area to the right is removed. See [`ChartBuilder::on()`] for more information and examples. */ @@ -243,7 +243,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartBuilder<'a, 'b, DB> { - `pos`: The position of the desired label area to adjust - `size`: The desired size of the label area in backend units (pixels). - If set to 0, the label area is removed. + If set to 0, the label area is removed. See [`ChartBuilder::on()`] for more information and examples. */ diff --git a/plotters/src/chart/context/cartesian3d/mod.rs b/plotters/src/chart/context/cartesian3d/mod.rs index ff28adf4..43d74f38 100644 --- a/plotters/src/chart/context/cartesian3d/mod.rs +++ b/plotters/src/chart/context/cartesian3d/mod.rs @@ -106,9 +106,9 @@ where /// Override the 3D projection matrix. This function allows to override the default projection /// matrix. /// - `pf`: A function that takes the default projection matrix configuration and returns the - /// projection matrix. This function will allow you to adjust the pitch, yaw angle and the - /// centeral point of the projection, etc. You can also build a projection matrix which is not - /// relies on the default configuration as well. + /// projection matrix. This function will allow you to adjust the pitch, yaw angle and the + /// centeral point of the projection, etc. You can also build a projection matrix which is not + /// relies on the default configuration as well. pub fn with_projection ProjectionMatrix>( &mut self, pf: P, diff --git a/plotters/src/coord/ranged1d/combinators/logarithmic.rs b/plotters/src/coord/ranged1d/combinators/logarithmic.rs index abcb24cc..cd1dfd5b 100644 --- a/plotters/src/coord/ranged1d/combinators/logarithmic.rs +++ b/plotters/src/coord/ranged1d/combinators/logarithmic.rs @@ -181,7 +181,7 @@ impl LogCoord { let a = V::from_f64(fv + self.zero_point); let b = V::from_f64(self.zero_point); - (V::as_f64(&a) - V::as_f64(&b)).abs() < std::f64::EPSILON + (V::as_f64(&a) - V::as_f64(&b)).abs() < f64::EPSILON } } diff --git a/plotters/src/coord/ranged1d/discrete.rs b/plotters/src/coord/ranged1d/discrete.rs index 8ae0e565..8b5da4b6 100644 --- a/plotters/src/coord/ranged1d/discrete.rs +++ b/plotters/src/coord/ranged1d/discrete.rs @@ -91,9 +91,10 @@ where /// - Add an extra dummy element after all the values in original discrete coordinate /// - Logically each value `v` from original coordinate system is mapped into an segment `[v, v+1)` where `v+1` denotes the successor of the `v` /// - Introduce two types of values `SegmentValue::Exact(value)` which denotes the left end of value's segment and `SegmentValue::CenterOf(value)` which refers the center of the segment. -/// This is used in histogram types, which uses a discrete coordinate as the buckets. The segmented coord always emits `CenterOf(value)` key points, thus it allows all the label and tick marks -/// of the coordinate rendered in the middle of each segment. -/// The corresponding trait [IntoSegmentedCoord](trait.IntoSegmentedCoord.html) is used to apply this decorator to coordinates. +/// This is used in histogram types, which uses a discrete coordinate as the buckets. +/// The segmented coord always emits `CenterOf(value)` key points, thus it allows all the label and tick marks +/// of the coordinate rendered in the middle of each segment. +/// The corresponding trait [IntoSegmentedCoord](trait.IntoSegmentedCoord.html) is used to apply this decorator to coordinates. #[derive(Clone)] pub struct SegmentedCoord(D); diff --git a/plotters/src/coord/ranged1d/mod.rs b/plotters/src/coord/ranged1d/mod.rs index 7b92d6e9..1b2072c2 100644 --- a/plotters/src/coord/ranged1d/mod.rs +++ b/plotters/src/coord/ranged1d/mod.rs @@ -186,12 +186,12 @@ pub trait Ranged { /// This marker decides if Plotters default [ValueFormatter](trait.ValueFormatter.html) implementation should be used. /// This associated type can be one of the following two types: /// - [DefaultFormatting](struct.DefaultFormatting.html) will allow Plotters to automatically impl - /// the formatter based on `Debug` trait, if `Debug` trait is not impl for the `Self::Value`, - /// [ValueFormatter](trait.ValueFormatter.html) will not impl unless you impl it manually. + /// the formatter based on `Debug` trait, if `Debug` trait is not impl for the `Self::Value`, + /// [ValueFormatter](trait.ValueFormatter.html) will not impl unless you impl it manually. /// /// - [NoDefaultFormatting](struct.NoDefaultFormatting.html) Disable the automatic `Debug` - /// based value formatting. Thus you have to impl the - /// [ValueFormatter](trait.ValueFormatter.html) manually. + /// based value formatting. Thus you have to impl the + /// [ValueFormatter](trait.ValueFormatter.html) manually. /// type FormatOption: DefaultValueFormatOption; diff --git a/plotters/src/coord/ranged1d/types/datetime.rs b/plotters/src/coord/ranged1d/types/datetime.rs index 62a0cce8..3ab62d11 100644 --- a/plotters/src/coord/ranged1d/types/datetime.rs +++ b/plotters/src/coord/ranged1d/types/datetime.rs @@ -163,9 +163,11 @@ impl TimeValue for DateTime { impl TimeValue for NaiveDateTime { type DateType = NaiveDate; + fn date_floor(&self) -> NaiveDate { self.date() } + fn date_ceil(&self) -> NaiveDate { if self.time().num_seconds_from_midnight() > 0 { self.date() + Duration::days(1) @@ -173,6 +175,7 @@ impl TimeValue for NaiveDateTime { self.date() } } + fn earliest_after_date(date: NaiveDate) -> NaiveDateTime { date.and_hms(0, 0, 0) } diff --git a/plotters/src/coord/ranged1d/types/mod.rs b/plotters/src/coord/ranged1d/types/mod.rs index 321b7cec..6a0fd864 100644 --- a/plotters/src/coord/ranged1d/types/mod.rs +++ b/plotters/src/coord/ranged1d/types/mod.rs @@ -9,7 +9,7 @@ pub use datetime::{ mod numeric; pub use numeric::{ RangedCoordf32, RangedCoordf64, RangedCoordi128, RangedCoordi32, RangedCoordi64, - RangedCoordu128, RangedCoordu32, RangedCoordu64, RangedCoordusize, RangedCoordisize, + RangedCoordisize, RangedCoordu128, RangedCoordu32, RangedCoordu64, RangedCoordusize, }; mod slice; diff --git a/plotters/src/coord/ranged1d/types/numeric.rs b/plotters/src/coord/ranged1d/types/numeric.rs index f11ab39e..8a9ab2d6 100644 --- a/plotters/src/coord/ranged1d/types/numeric.rs +++ b/plotters/src/coord/ranged1d/types/numeric.rs @@ -125,7 +125,7 @@ macro_rules! gen_key_points_comp { assert!(!(range.0.is_nan() || range.1.is_nan())); - if (range.0 - range.1).abs() < std::f64::EPSILON { + if (range.0 - range.1).abs() < f64::EPSILON { return vec![range.0 as $type]; } @@ -141,7 +141,7 @@ macro_rules! gen_key_points_comp { } else { a - (a / b).ceil() * b }; - if (ret - b).abs() < std::f64::EPSILON { + if (ret - b).abs() < f64::EPSILON { 0.0 } else { ret @@ -191,7 +191,7 @@ macro_rules! gen_key_points_comp { let left_base = (left / value_granularity).floor() * value_granularity; let mut left_relative = left - left_base; let right = range.1 - rem_euclid(range.1, scale); - while (right - left_relative - left_base) >= -std::f64::EPSILON { + while (right - left_relative - left_base) >= -f64::EPSILON { let new_left_relative = (left_relative / value_granularity).round() * value_granularity; if new_left_relative < 0.0 { diff --git a/plotters/src/data/quartiles.rs b/plotters/src/data/quartiles.rs index 054f51d1..78613dad 100644 --- a/plotters/src/data/quartiles.rs +++ b/plotters/src/data/quartiles.rs @@ -19,7 +19,7 @@ impl Quartiles { assert!(0_f64 <= pct); let hundred = 100_f64; assert!(pct <= hundred); - if (pct - hundred).abs() < std::f64::EPSILON { + if (pct - hundred).abs() < f64::EPSILON { return s[s.len() - 1].into(); } let length = (s.len() - 1) as f64; diff --git a/plotters/src/drawing/area.rs b/plotters/src/drawing/area.rs index da8622c3..e8981fea 100644 --- a/plotters/src/drawing/area.rs +++ b/plotters/src/drawing/area.rs @@ -258,12 +258,12 @@ impl DrawingArea { /// Compute the relative size based on the drawing area's height pub fn relative_to_height(&self, p: f64) -> f64 { - f64::from((self.rect.y1 - self.rect.y0).max(0)) * (p.min(1.0).max(0.0)) + f64::from((self.rect.y1 - self.rect.y0).max(0)) * (p.clamp(0.0, 1.0)) } /// Compute the relative size based on the drawing area's width pub fn relative_to_width(&self, p: f64) -> f64 { - f64::from((self.rect.x1 - self.rect.x0).max(0)) * (p.min(1.0).max(0.0)) + f64::from((self.rect.x1 - self.rect.x0).max(0)) * (p.clamp(0.0, 1.0)) } /// Get the pixel range of this area @@ -669,13 +669,13 @@ mod drawing_area_tests { for row in 0..=nyb { for col in 0..=nxb { let get_bp = |full, limit, id| { - (if id == 0 { + if id == 0 { 0 } else if id > limit { full } else { breaks[id as usize - 1] - }) + } }; let expected_u = (get_bp(1024, nxb, col), get_bp(768, nyb, row)); diff --git a/plotters/src/element/image.rs b/plotters/src/element/image.rs index a1e5f8bd..6c31c2d8 100644 --- a/plotters/src/element/image.rs +++ b/plotters/src/element/image.rs @@ -89,7 +89,7 @@ impl<'a, Coord, P: PixelFormat> BitMapElement<'a, Coord, P> { /// - `size`: The size of the bitmap /// - `buf`: The buffer to use /// - **returns**: The newly created image element, if the buffer isn't fit the image - /// dimension, this will returns an `None`. + /// dimension, this will returns an `None`. pub fn with_owned_buffer(pos: Coord, size: (u32, u32), buf: Vec) -> Option { if buf.len() < (size.0 * size.1) as usize * P::PIXEL_SIZE { return None; @@ -109,7 +109,7 @@ impl<'a, Coord, P: PixelFormat> BitMapElement<'a, Coord, P> { /// - `size`: The size of the bitmap /// - `buf`: The buffer to use /// - **returns**: The newly created image element, if the buffer isn't fit the image - /// dimension, this will returns an `None`. + /// dimension, this will returns an `None`. pub fn with_mut(pos: Coord, size: (u32, u32), buf: &'a mut [u8]) -> Option { if buf.len() < (size.0 * size.1) as usize * P::PIXEL_SIZE { return None; @@ -130,7 +130,7 @@ impl<'a, Coord, P: PixelFormat> BitMapElement<'a, Coord, P> { /// - `size`: The size of the bitmap /// - `buf`: The buffer to use /// - **returns**: The newly created image element, if the buffer isn't fit the image - /// dimension, this will returns an `None`. + /// dimension, this will returns an `None`. pub fn with_ref(pos: Coord, size: (u32, u32), buf: &'a [u8]) -> Option { if buf.len() < (size.0 * size.1) as usize * P::PIXEL_SIZE { return None; diff --git a/plotters/src/element/text.rs b/plotters/src/element/text.rs index e066fde4..9baa2016 100644 --- a/plotters/src/element/text.rs +++ b/plotters/src/element/text.rs @@ -1,5 +1,4 @@ use std::borrow::Borrow; -use std::i32; use super::{Drawable, PointCollection}; use crate::style::{FontDesc, FontResult, LayoutBox, TextStyle}; diff --git a/plotters/src/evcxr.rs b/plotters/src/evcxr.rs index 07401724..9d7b9666 100644 --- a/plotters/src/evcxr.rs +++ b/plotters/src/evcxr.rs @@ -48,8 +48,7 @@ pub fn evcxr_figure< SVGWrapper(buffer, "".to_string()) } -// An evcxr figure that can save to the local file system and render in a notebook. - +/// An evcxr figure that can save to the local file system and render in a notebook. pub fn evcxr_figure_with_saving< Draw: FnOnce(DrawingArea) -> Result<(), Box>, >( @@ -77,8 +76,9 @@ pub fn evcxr_bitmap_figure< draw: Draw, ) -> SVGWrapper { const PIXEL_SIZE: usize = 3; - let mut buf = Vec::new(); - buf.resize((size.0 as usize) * (size.1 as usize) * PIXEL_SIZE, 0); + + let mut buf = vec![0; (size.0 as usize) * (size.1 as usize) * PIXEL_SIZE]; + let root = BitMapBackend::with_buffer(&mut buf, size).into_drawing_area(); draw(root).expect("Drawing failure"); let mut buffer = "".to_string(); diff --git a/plotters/src/lib.rs b/plotters/src/lib.rs index 8bcd4bfb..230c679f 100644 --- a/plotters/src/lib.rs +++ b/plotters/src/lib.rs @@ -1,4 +1,5 @@ #![warn(missing_docs)] +#![allow(clippy::type_complexity)] #![cfg_attr(doc_cfg, feature(doc_cfg))] /*! @@ -420,19 +421,19 @@ Also, there's a static HTML version of this notebook available at [this location Rust is a perfect language for data visualization. Although there are many mature visualization libraries in many different languages, Rust is one of the best languages that fits the need. * **Easy to use** Rust has a very good iterator system built into the standard library. With the help of iterators, -plotting in Rust can be as easy as most of the high-level programming languages. The Rust based plotting library -can be very easy to use. + plotting in Rust can be as easy as most of the high-level programming languages. The Rust based plotting library + can be very easy to use. * **Fast** If you need to render a figure with trillions of data points, -Rust is a good choice. Rust's performance allows you to combine the data processing step -and rendering step into a single application. When plotting in high-level programming languages, -e.g. Javascript or Python, data points must be down-sampled before feeding into the plotting -program because of the performance considerations. Rust is fast enough to do the data processing and visualization -within a single program. You can also integrate the -figure rendering code into your application to handle a huge amount of data and visualize it in real-time. + Rust is a good choice. Rust's performance allows you to combine the data processing step + and rendering step into a single application. When plotting in high-level programming languages, + e.g. Javascript or Python, data points must be down-sampled before feeding into the plotting + program because of the performance considerations. Rust is fast enough to do the data processing and visualization + within a single program. You can also integrate the + figure rendering code into your application to handle a huge amount of data and visualize it in real-time. * **WebAssembly Support** Rust is one of the languages with the best WASM support. Plotting in Rust could be -very useful for visualization on a web page and would have a huge performance improvement comparing to Javascript. + very useful for visualization on a web page and would have a huge performance improvement comparing to Javascript. ## Plotting on HTML5 canvas with WASM Backend @@ -803,10 +804,6 @@ pub mod evcxr; #[cfg(test)] pub use crate::drawing::{check_color, create_mocked_drawing_area}; -#[cfg(feature = "palette_ext")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "palette_ext")))] -pub use palette; - /// The module imports the most commonly used types and modules in Plotters pub mod prelude { // Chart related types diff --git a/plotters/src/series/line_series.rs b/plotters/src/series/line_series.rs index ed92d56f..913366a7 100644 --- a/plotters/src/series/line_series.rs +++ b/plotters/src/series/line_series.rs @@ -86,7 +86,7 @@ impl LineSeries { } } -/// A dashed line series, map an iterable object to the dashed line element. Can be used to draw simple dashed and dotted lines. +/// A dashed line series, map an iterable object to the dashed line element. Can be used to draw simple dashed and dotted lines. /// /// If you want to use more complex shapes as points in the line, you can use `plotters::series::line_series::DottedLineSeries`. /// diff --git a/plotters/src/style/color.rs b/plotters/src/style/color.rs index 7e372cd1..2a5fbf02 100644 --- a/plotters/src/style/color.rs +++ b/plotters/src/style/color.rs @@ -137,9 +137,9 @@ impl Color for HSLColor { #[allow(clippy::many_single_char_names)] fn to_backend_color(&self) -> BackendColor { let (h, s, l) = ( - self.0.min(1.0).max(0.0), - self.1.min(1.0).max(0.0), - self.2.min(1.0).max(0.0), + self.0.clamp(0.0, 1.0), + self.1.clamp(0.0, 1.0), + self.2.clamp(0.0, 1.0), ); if s == 0.0 { diff --git a/plotters/src/style/font/ttf.rs b/plotters/src/style/font/ttf.rs index 9029df55..5d5a7209 100644 --- a/plotters/src/style/font/ttf.rs +++ b/plotters/src/style/font/ttf.rs @@ -1,7 +1,6 @@ use std::borrow::{Borrow, Cow}; use std::cell::RefCell; use std::collections::HashMap; -use std::i32; use std::sync::{Arc, RwLock}; use lazy_static::lazy_static; @@ -82,7 +81,9 @@ impl FontExt { _ => unreachable!(), }; let face = unsafe { - std::mem::transmute::<_, Option>>(ttf_parser::Face::parse(data, idx).ok()) + std::mem::transmute::, Option>>( + ttf_parser::Face::parse(data, idx).ok(), + ) }; Self { inner: font, face } }