Shl
trait Shl<T>
Source: compiler/src/builtin_docs/prelude/ops.hy The left shift operator <<.
a << n on a type with a Shl instance calls shl(a, n). The shift
count is always an int, whatever the type of a, and the result has
the type of a. int and byte have builtin instances; shifting a
byte keeps the low 8 bits.
Required methods#
| Name | Description |
|---|---|
shl | Returns a shifted left by n bits. |
Examples#
use tests::assert;
class Flags {
pub bits: int,
}
impl Shl for Flags {
pub fn shl(Flags a, int n) -> Flags {
return new Flags(a.bits << n);
}
}
fn main() {
let f = new Flags(1) << 3;
assert!(f.bits == 8);
}