Lines Matching refs:T

39 fn fits_within<T: Integer>(value: T, num_bits: u32) -> bool {  in fits_within()  argument
40 fits_within!(value, T, num_bits) in fits_within()
230 pub struct Bounded<T: Integer, const N: u32>(T);
276 impl<T, const N: u32> Bounded<T, N>
278 T: Integer,
287 const fn __new(value: T) -> Self { in __new()
293 assert!(N <= T::BITS); in __new()
329 pub fn try_new(value: T) -> Option<Self> { in try_new()
367 pub fn from_expr(expr: T) -> Self { in from_expr()
387 pub fn get(self) -> T { in get() argument
405 pub const fn extend<const M: u32>(self) -> Bounded<T, M> { in extend() argument
436 pub fn try_shrink<const M: u32>(self) -> Option<Bounded<T, M>> { in try_shrink() argument
437 Bounded::<T, M>::try_new(self.get()) in try_shrink()
461 U: TryFrom<T> + Integer, in cast()
462 T: Integer, in cast()
463 U: Integer<Signedness = T::Signedness>, in cast()
475 impl<T, const N: u32> Deref for Bounded<T, N>
477 T: Integer,
479 type Target = T;
508 pub trait TryIntoBounded<T: Integer, const N: u32> {
512 fn try_into_bounded(self) -> Option<Bounded<T, N>>; in try_into_bounded() argument
516 impl<T, U, const N: u32> TryIntoBounded<T, N> for U
518 T: Integer,
519 U: TryInto<T>,
521 fn try_into_bounded(self) -> Option<Bounded<T, N>> { in try_into_bounded() argument
528 impl<T, U, const N: u32, const M: u32> PartialEq<Bounded<U, M>> for Bounded<T, N>
530 T: Integer,
532 T: PartialEq<U>,
539 impl<T, const N: u32> Eq for Bounded<T, N> where T: Integer {}
541 impl<T, U, const N: u32, const M: u32> PartialOrd<Bounded<U, M>> for Bounded<T, N>
543 T: Integer,
545 T: PartialOrd<U>,
552 impl<T, const N: u32> Ord for Bounded<T, N>
554 T: Integer,
555 T: Ord,
564 impl<T, const N: u32> PartialEq<T> for Bounded<T, N>
566 T: Integer,
567 T: PartialEq,
569 fn eq(&self, other: &T) -> bool { in eq()
574 impl<T, const N: u32> PartialOrd<T> for Bounded<T, N>
576 T: Integer,
577 T: PartialOrd,
579 fn partial_cmp(&self, other: &T) -> Option<cmp::Ordering> { in partial_cmp()
586 impl<T, const N: u32, const M: u32> ops::Add<Bounded<T, M>> for Bounded<T, N>
588 T: Integer,
589 T: ops::Add<Output = T>,
591 type Output = T;
593 fn add(self, rhs: Bounded<T, M>) -> Self::Output { in add() argument
598 impl<T, const N: u32, const M: u32> ops::BitAnd<Bounded<T, M>> for Bounded<T, N>
600 T: Integer,
601 T: ops::BitAnd<Output = T>,
603 type Output = T;
605 fn bitand(self, rhs: Bounded<T, M>) -> Self::Output { in bitand() argument
610 impl<T, const N: u32, const M: u32> ops::BitOr<Bounded<T, M>> for Bounded<T, N>
612 T: Integer,
613 T: ops::BitOr<Output = T>,
615 type Output = T;
617 fn bitor(self, rhs: Bounded<T, M>) -> Self::Output { in bitor() argument
622 impl<T, const N: u32, const M: u32> ops::BitXor<Bounded<T, M>> for Bounded<T, N>
624 T: Integer,
625 T: ops::BitXor<Output = T>,
627 type Output = T;
629 fn bitxor(self, rhs: Bounded<T, M>) -> Self::Output { in bitxor() argument
634 impl<T, const N: u32, const M: u32> ops::Div<Bounded<T, M>> for Bounded<T, N>
636 T: Integer,
637 T: ops::Div<Output = T>,
639 type Output = T;
641 fn div(self, rhs: Bounded<T, M>) -> Self::Output { in div() argument
646 impl<T, const N: u32, const M: u32> ops::Mul<Bounded<T, M>> for Bounded<T, N>
648 T: Integer,
649 T: ops::Mul<Output = T>,
651 type Output = T;
653 fn mul(self, rhs: Bounded<T, M>) -> Self::Output { in mul() argument
658 impl<T, const N: u32, const M: u32> ops::Rem<Bounded<T, M>> for Bounded<T, N>
660 T: Integer,
661 T: ops::Rem<Output = T>,
663 type Output = T;
665 fn rem(self, rhs: Bounded<T, M>) -> Self::Output { in rem() argument
670 impl<T, const N: u32, const M: u32> ops::Sub<Bounded<T, M>> for Bounded<T, N>
672 T: Integer,
673 T: ops::Sub<Output = T>,
675 type Output = T;
677 fn sub(self, rhs: Bounded<T, M>) -> Self::Output { in sub() argument
684 impl<T, const N: u32> ops::Add<T> for Bounded<T, N>
686 T: Integer,
687 T: ops::Add<Output = T>,
689 type Output = T;
691 fn add(self, rhs: T) -> Self::Output { in add()
696 impl<T, const N: u32> ops::BitAnd<T> for Bounded<T, N>
698 T: Integer,
699 T: ops::BitAnd<Output = T>,
701 type Output = T;
703 fn bitand(self, rhs: T) -> Self::Output { in bitand()
708 impl<T, const N: u32> ops::BitOr<T> for Bounded<T, N>
710 T: Integer,
711 T: ops::BitOr<Output = T>,
713 type Output = T;
715 fn bitor(self, rhs: T) -> Self::Output { in bitor()
720 impl<T, const N: u32> ops::BitXor<T> for Bounded<T, N>
722 T: Integer,
723 T: ops::BitXor<Output = T>,
725 type Output = T;
727 fn bitxor(self, rhs: T) -> Self::Output { in bitxor()
732 impl<T, const N: u32> ops::Div<T> for Bounded<T, N>
734 T: Integer,
735 T: ops::Div<Output = T>,
737 type Output = T;
739 fn div(self, rhs: T) -> Self::Output { in div()
744 impl<T, const N: u32> ops::Mul<T> for Bounded<T, N>
746 T: Integer,
747 T: ops::Mul<Output = T>,
749 type Output = T;
751 fn mul(self, rhs: T) -> Self::Output { in mul()
756 impl<T, const N: u32> ops::Neg for Bounded<T, N>
758 T: Integer,
759 T: ops::Neg<Output = T>,
761 type Output = T;
768 impl<T, const N: u32> ops::Not for Bounded<T, N>
770 T: Integer,
771 T: ops::Not<Output = T>,
773 type Output = T;
780 impl<T, const N: u32> ops::Rem<T> for Bounded<T, N>
782 T: Integer,
783 T: ops::Rem<Output = T>,
785 type Output = T;
787 fn rem(self, rhs: T) -> Self::Output { in rem()
792 impl<T, const N: u32> ops::Sub<T> for Bounded<T, N>
794 T: Integer,
795 T: ops::Sub<Output = T>,
797 type Output = T;
799 fn sub(self, rhs: T) -> Self::Output { in sub()
806 impl<T, const N: u32> fmt::Display for Bounded<T, N>
808 T: Integer,
809 T: fmt::Display,
816 impl<T, const N: u32> fmt::Binary for Bounded<T, N>
818 T: Integer,
819 T: fmt::Binary,
826 impl<T, const N: u32> fmt::LowerExp for Bounded<T, N>
828 T: Integer,
829 T: fmt::LowerExp,
836 impl<T, const N: u32> fmt::LowerHex for Bounded<T, N>
838 T: Integer,
839 T: fmt::LowerHex,
846 impl<T, const N: u32> fmt::Octal for Bounded<T, N>
848 T: Integer,
849 T: fmt::Octal,
856 impl<T, const N: u32> fmt::UpperExp for Bounded<T, N>
858 T: Integer,
859 T: fmt::UpperExp,
866 impl<T, const N: u32> fmt::UpperHex for Bounded<T, N>
868 T: Integer,
869 T: fmt::UpperHex,
882 impl<T> $trait for Bounded<T, $num_bits> where T: Integer {}
903 impl<T> AtLeastXBits<32> for T where T: AtLeastXBits<64> {} implementation
913 impl<T> AtLeastXBits<16> for T where T: AtLeastXBits<32> {} implementation
921 impl<T> AtLeastXBits<8> for T where T: AtLeastXBits<16> {} implementation
940 impl<T, const N: u32> From<$type> for Bounded<T, N>
943 T: Integer<Signedness = <$type as Integer>::Signedness> + From<$type>,
949 Self::__new(T::from(value))
977 impl<T> FitsInXBits<16> for T where T: FitsInXBits<8> {} implementation
982 impl<T> FitsInXBits<32> for T where T: FitsInXBits<16> {} implementation
990 impl<T> FitsInXBits<64> for T where T: FitsInXBits<32> {} implementation
1016 impl<T, const N: u32> From<Bounded<T, N>> for $type
1018 $type: Integer + TryFrom<T>,
1019 T: Integer<Signedness = <$type as Integer>::Signedness>,
1020 Bounded<T, N>: FitsInXBits<{ <$type as Integer>::BITS as usize }>,
1022 fn from(value: Bounded<T, N>) -> $type {
1040 impl<T> From<Bounded<T, 1>> for bool
1042 T: Integer + Zeroable,
1044 fn from(value: Bounded<T, 1>) -> Self { in from() argument
1049 impl<T, const N: u32> From<bool> for Bounded<T, N>
1051 T: Integer + From<bool>,
1056 Self::__new(T::from(value)) in from()