From f4471b7d2ac4b1da3f41f23bacff1a80360cb014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nurzhan=20Sak=C3=A9n?= Date: Fri, 15 Dec 2023 13:32:30 +0400 Subject: [PATCH] Make private traits used in bounds public --- src/func.rs | 1 - src/iter.rs | 14 ++++++-------- src/lib.rs | 4 +++- src/util.rs | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/func.rs b/src/func.rs index 3868ba3..9a90387 100644 --- a/src/func.rs +++ b/src/func.rs @@ -54,7 +54,6 @@ use core::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Range, Rem, Sub, SubAs /// /// This is slightly more optimized than the iterator version, but uses internal iteration. Unlike /// the iterator version, vertical and horizontal lines will always be traversed in an ascending order. -#[allow(private_bounds)] pub fn clipline( line: (Point, Point), clip_rect: (Point, Point), diff --git a/src/iter.rs b/src/iter.rs index a41c166..5c94148 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,10 +1,11 @@ -use crate::util::{ - bresenham_step, clip_rect_entry, clip_rect_exit, destandardize, standardize, Constant, Point, -}; use core::cmp::{max, min}; use core::iter::FusedIterator; use core::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Rem, Sub, SubAssign}; +use crate::util::{ + bresenham_step, clip_rect_entry, clip_rect_exit, destandardize, standardize, Constant, Point, +}; + /// Enum representing the different variants of clipped line segment iterators. /// /// This enum allows you to iterate over different types of line segments, @@ -165,7 +166,6 @@ struct Bresenham { term: T, } -#[allow(private_bounds)] impl Clipline where T: Copy @@ -235,7 +235,6 @@ where } } -#[allow(private_bounds)] impl Vlipline where T: Ord + Neg + Constant, @@ -288,7 +287,6 @@ where } } -#[allow(private_bounds)] impl Hlipline where T: Ord + Neg + Constant, @@ -694,8 +692,8 @@ where // ----------------------------------------------- /// The absolute difference operation. -trait AbsDiff { - /// The resulting type after applying the `+` operator. +pub trait AbsDiff { + /// The resulting type after applying the `abs_diff` operation. type Output; /// Computes the absolute difference between `self` and `other`. diff --git a/src/lib.rs b/src/lib.rs index 6238b05..a71f22e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,4 +22,6 @@ mod util; #[cfg(feature = "func")] pub use func::clipline; #[cfg(feature = "iter")] -pub use iter::{Clipline, Gentleham, Hlipline, Steepnham, Vlipline}; +pub use iter::{AbsDiff, Clipline, Gentleham, Hlipline, Steepnham, Vlipline}; +#[cfg(any(feature = "func", feature = "iter"))] +pub use util::Constant; diff --git a/src/util.rs b/src/util.rs index 97db076..f3b5ba2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -209,7 +209,8 @@ where (err, xyd, yxd) } -pub(crate) trait Constant { +/// Provides constants for `0`, `1` and `2`. +pub trait Constant { type Output; const ZERO: Self::Output;