Integral
trait Integral<T: Num + Shl + Shr + BitAnd + BitOr + BitXor + BitNot>
Source: compiler/src/builtin_docs/prelude/ops.hy The integer bundle: Num plus Shl, Shr, BitAnd, BitOr, BitXor and BitNot.
Integral has no methods of its own. A bound T: Integral allows the
arithmetic, shift and bitwise operators on T. Only int is Integral
(float is Num but not Integral).
Examples#
use tests::assert;
fn low_bits<T: Integral>(T x, T mask) -> T {
return x & mask;
}
fn main() {
assert!(low_bits(13, 3) == 1);
}