Skip to content

Commit 65b0b03

Browse files
author
Ian
committed
Added UIndex type in order to use it in single-sparse
1 parent 26d5094 commit 65b0b03

3 files changed

Lines changed: 48 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "single-utilities"
3-
version = "0.8.0"
3+
version = "0.8.1"
44
edition = "2024"
55
description = "This crate provdes types, traits and utility functions to the single-rust ecosystem that can be universally used. You can also use it within your own ecosystem 👀"
66
homepage = "https://singlerust.com"

src/traits/mod.rs

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
1+
use num_traits::float::FloatCore;
2+
use num_traits::{Bounded, FromPrimitive, NumCast, One, ToPrimitive, Unsigned, Zero};
3+
#[cfg(feature = "simd")]
4+
use simba::{scalar::RealField, simd::SimdRealField};
15
use std::fmt::Debug;
26
use std::iter::Sum;
3-
use num_traits::{Bounded, FromPrimitive, NumCast, One, ToPrimitive, Zero};
4-
#[cfg(feature="simd")]
5-
use simba::{scalar::RealField, simd::SimdRealField};
67
use std::ops::{Add, AddAssign, MulAssign, SubAssign};
7-
use num_traits::float::FloatCore;
88

99
pub trait NumericOps:
10-
Zero + One + NumCast + Copy + AddAssign + MulAssign + SubAssign + PartialOrd + Bounded + Add<Output = Self> + Sum + Debug + Default
10+
Zero
11+
+ One
12+
+ NumCast
13+
+ Copy
14+
+ AddAssign
15+
+ MulAssign
16+
+ SubAssign
17+
+ PartialOrd
18+
+ Bounded
19+
+ Add<Output = Self>
20+
+ Sum
21+
+ Debug
22+
+ Default
1123
{
1224
}
1325
impl<
14-
T: Zero + One + NumCast + Copy + AddAssign + MulAssign + SubAssign + PartialOrd + Bounded + Add<Output = Self> + Sum + Debug + Default,
26+
T: Zero
27+
+ One
28+
+ NumCast
29+
+ Copy
30+
+ AddAssign
31+
+ MulAssign
32+
+ SubAssign
33+
+ PartialOrd
34+
+ Bounded
35+
+ Add<Output = Self>
36+
+ Sum
37+
+ Debug
38+
+ Default,
1539
> NumericOps for T
1640
{
1741
}
@@ -20,18 +44,21 @@ pub trait NumericOpsTS: NumericOps + Send + Sync {}
2044

2145
impl<T: NumericOps + Send + Sync> NumericOpsTS for T {}
2246

23-
pub trait FloatOps: NumericOps + num_traits::Float + FromPrimitive + ToPrimitive + FloatCore {}
47+
pub trait FloatOps:
48+
NumericOps + num_traits::Float + FromPrimitive + ToPrimitive + FloatCore
49+
{
50+
}
2451

2552
impl<T: NumericOps + num_traits::Float + FromPrimitive + ToPrimitive + FloatCore> FloatOps for T {}
2653

2754
pub trait FloatOpsTS: FloatOps + Sync + Send {}
2855

2956
impl<T: FloatOps + Send + Sync> FloatOpsTS for T {}
3057

31-
#[cfg(feature="simd")]
58+
#[cfg(feature = "simd")]
3259
pub trait FloatOpsTSSimba: FloatOpsTS + SimdRealField + RealField {}
3360

34-
#[cfg(feature="simd")]
61+
#[cfg(feature = "simd")]
3562
impl<T: FloatOpsTS + SimdRealField + RealField> FloatOpsTSSimba for T {}
3663

3764
// Define a type alias for our numeric constraints
@@ -57,3 +84,13 @@ impl<T: Default + Clone> ZeroVec for Vec<T> {
5784
self.extend(std::iter::repeat_n(T::default(), len));
5885
}
5986
}
87+
88+
pub trait UIndex:
89+
Unsigned + Zero + One + Copy + PartialEq + PartialOrd + From<usize> + Into<usize>
90+
{
91+
}
92+
93+
impl<I: Unsigned + Zero + One + Copy + PartialEq + PartialOrd + From<usize> + Into<usize>> UIndex
94+
for I
95+
{
96+
}

0 commit comments

Comments
 (0)