Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make private traits used in bounds public #8

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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