Skip to content

Commit

Permalink
Merge pull request #8 from nxsaken/priv-traits-make-pub
Browse files Browse the repository at this point in the history
Make private traits used in bounds public
  • Loading branch information
nxsaken committed Dec 15, 2023
2 parents d21d939 + f4471b7 commit bf61b68
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, F>(
line: (Point<T>, Point<T>),
clip_rect: (Point<T>, Point<T>),
Expand Down
14 changes: 6 additions & 8 deletions src/iter.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -165,7 +166,6 @@ struct Bresenham<T> {
term: T,
}

#[allow(private_bounds)]
impl<T> Clipline<T>
where
T: Copy
Expand Down Expand Up @@ -235,7 +235,6 @@ where
}
}

#[allow(private_bounds)]
impl<T> Vlipline<T>
where
T: Ord + Neg<Output = T> + Constant<Output = T>,
Expand Down Expand Up @@ -288,7 +287,6 @@ where
}
}

#[allow(private_bounds)]
impl<T> Hlipline<T>
where
T: Ord + Neg<Output = T> + Constant<Output = T>,
Expand Down Expand Up @@ -694,8 +692,8 @@ where
// -----------------------------------------------

/// The absolute difference operation.
trait AbsDiff<Rhs = Self> {
/// The resulting type after applying the `+` operator.
pub trait AbsDiff<Rhs = Self> {
/// The resulting type after applying the `abs_diff` operation.
type Output;

/// Computes the absolute difference between `self` and `other`.
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bf61b68

Please sign in to comment.