Skip to content

Commit

Permalink
Merge branch 'zero-marker' of git://github.com/jerry73204/typenum int…
Browse files Browse the repository at this point in the history
…o jerry73204-zero-marker
  • Loading branch information
paholg committed Mar 12, 2021
2 parents b62d84b + 4e145da commit 98a8903
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! - From `core::ops`: `BitAnd`, `BitOr`, `BitXor`, and `Not`.
//! - From `typenum`: `Same` and `Cmp`.

use crate::{private::InternalMarker, Cmp, Equal, Greater, Less, NonZero, PowerOfTwo};
use crate::{private::InternalMarker, Cmp, Equal, Greater, Less, NonZero, PowerOfTwo, Zero};
use core::ops::{BitAnd, BitOr, BitXor, Not};

pub use crate::marker_traits::Bit;
Expand Down Expand Up @@ -74,6 +74,7 @@ impl Bit for B1 {
}
}

impl Zero for B0 {}
impl NonZero for B1 {}
impl PowerOfTwo for B1 {}

Expand Down
3 changes: 2 additions & 1 deletion src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{
consts::{N1, P1, U0, U1},
private::{Internal, InternalMarker, PrivateDivInt, PrivateIntegerAdd, PrivateRem},
uint::{UInt, Unsigned},
Cmp, Equal, Greater, Less, NonZero, Pow, PowerOfTwo,
Cmp, Equal, Greater, Less, NonZero, Pow, PowerOfTwo, Zero,
};
use core::ops::{Add, Div, Mul, Neg, Rem, Sub};

Expand Down Expand Up @@ -78,6 +78,7 @@ impl Z0 {

impl<U: Unsigned + NonZero> NonZero for PInt<U> {}
impl<U: Unsigned + NonZero> NonZero for NInt<U> {}
impl Zero for Z0 {}

impl<U: Unsigned + NonZero + PowerOfTwo> PowerOfTwo for PInt<U> {}

Expand Down
4 changes: 4 additions & 0 deletions src/marker_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
/// crate implement `NonZero` except `B0`, `U0`, and `Z0`.
pub trait NonZero {}

/// A **marker trait** to designate that a type is zero. Only `B0`, `U0`, and `Z0`
/// implement this trait.
pub trait Zero {}

/// A **Marker trait** for the types `Greater`, `Equal`, and `Less`.
///
/// This trait should not be implemented for anything outside this crate.
Expand Down
1 change: 0 additions & 1 deletion src/operator_aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//!
//! assert_type_eq!(X, Y);
//! ```
//!

// Aliases!!!
use crate::type_operators::{
Expand Down
3 changes: 2 additions & 1 deletion src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::{
},
Add1, Cmp, Double, Equal, Gcd, Gcf, GrEq, Greater, IsGreaterOrEqual, Len, Length, Less, Log2,
Logarithm2, Maximum, Minimum, NonZero, Or, Ord, Pow, Prod, Shleft, Shright, Sqrt, Square,
SquareRoot, Sub1, Sum,
SquareRoot, Sub1, Sum, Zero,
};
use core::ops::{Add, BitAnd, BitOr, BitXor, Mul, Shl, Shr, Sub};

Expand Down Expand Up @@ -229,6 +229,7 @@ impl<U: Unsigned, B: Bit> Unsigned for UInt<U, B> {
}

impl<U: Unsigned, B: Bit> NonZero for UInt<U, B> {}
impl Zero for UTerm {}

impl PowerOfTwo for UInt<UTerm, B1> {}
impl<U: Unsigned + PowerOfTwo> PowerOfTwo for UInt<U, B0> {}
Expand Down

0 comments on commit 98a8903

Please sign in to comment.