Skip to content

Commit 5c50135

Browse files
authored
Publicize internal traits to let users write generic fns
1 parent 3dee59e commit 5c50135

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ pub use crate::statistics::*;
136136
mod statistics;
137137

138138
#[cfg(feature = "core")]
139+
pub use crate::util::{FloatingPoint, ComplexFloating, RealFloating, RealNumber};
139140
pub use crate::util::{get_size, HasAfEnum, ImplicitPromote};
141+
pub use crate::util::{GrayRGBConvertible, ImageFilterType, ImageNativeType, Scanable};
142+
pub use crate::util::{CovarianceComputable, EdgeComputable, MedianComputable, MomentsComputable};
140143
#[cfg(feature = "core")]
141144
mod util;
142145

src/util.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ impl Zero for Complex32 {
608608
}
609609
}
610610

611+
///Trait qualifier to accept either real or complex typed data
611612
pub trait FloatingPoint {
612613
fn is_real() -> bool {
613614
false
@@ -638,16 +639,19 @@ impl FloatingPoint for f32 {
638639
}
639640
}
640641

642+
///Trait qualifier to accept real data(numbers)
641643
pub trait RealFloating {}
642644

643645
impl RealFloating for f64 {}
644646
impl RealFloating for f32 {}
645647

648+
///Trait qualifier to accept complex data(numbers)
646649
pub trait ComplexFloating {}
647650

648651
impl ComplexFloating for Complex64 {}
649652
impl ComplexFloating for Complex32 {}
650653

654+
///Trait qualifier indicating it can hold real numbers only
651655
pub trait RealNumber {}
652656

653657
impl RealNumber for f64 {}
@@ -661,19 +665,24 @@ impl RealNumber for bool {}
661665
impl RealNumber for u64 {}
662666
impl RealNumber for i64 {}
663667

668+
///Trait qualifier for the type of Arrays accepted by scan operations
664669
pub trait Scanable {}
665670

666671
impl Scanable for i32 {}
667672
impl Scanable for u32 {}
668673
impl Scanable for u64 {}
669674
impl Scanable for i64 {}
670675

676+
/// Trait qualifier for type of Array's that are accepted
677+
/// by native image load/save functions.
671678
pub trait ImageNativeType {}
672679

673680
impl ImageNativeType for f32 {}
674681
impl ImageNativeType for u16 {}
675682
impl ImageNativeType for u8 {}
676683

684+
/// Trait qualifier for type of Array's that are accepted
685+
/// by image processing functions especially filtering algorithms
677686
pub trait ImageFilterType {}
678687

679688
impl ImageFilterType for f64 {}
@@ -686,6 +695,8 @@ impl ImageFilterType for u8 {}
686695
impl ImageFilterType for bool {}
687696

688697
// TODO Rust haven't stabilized trait aliases yet
698+
/// Trait qualifier for given type indicating conversion capability between
699+
/// grayscale and RGB triplets of data
689700
pub trait GrayRGBConvertible {}
690701

691702
impl GrayRGBConvertible for f64 {}
@@ -697,6 +708,7 @@ impl GrayRGBConvertible for u16 {}
697708
impl GrayRGBConvertible for u8 {}
698709

699710
// TODO Rust haven't stabilized trait aliases yet
711+
/// Trait qualifier for given type indicating computability of Moments
700712
pub trait MomentsComputable {}
701713

702714
impl MomentsComputable for f64 {}
@@ -708,6 +720,7 @@ impl MomentsComputable for u16 {}
708720
impl MomentsComputable for u8 {}
709721

710722
// TODO Rust haven't stabilized trait aliases yet
723+
/// Trait qualifier for given type indicating computability of Median
711724
pub trait MedianComputable {}
712725

713726
impl MedianComputable for f64 {}
@@ -719,6 +732,8 @@ impl MedianComputable for u16 {}
719732
impl MedianComputable for u8 {}
720733

721734
// TODO Rust haven't stabilized trait aliases yet
735+
/// Trait qualifier for given type indicating if edge calculations such as
736+
/// derivates etc. can be performed
722737
pub trait EdgeComputable {}
723738

724739
impl EdgeComputable for f64 {}
@@ -729,6 +744,7 @@ impl EdgeComputable for i16 {}
729744
impl EdgeComputable for u16 {}
730745
impl EdgeComputable for u8 {}
731746

747+
/// Trait qualifier for given type indicating computability of covariance
732748
pub trait CovarianceComputable {}
733749

734750
impl CovarianceComputable for f64 {}

0 commit comments

Comments
 (0)