rustybuzz/hb/
algs.rs

1// FLAG macro in harfbuzz.
2#[inline]
3pub const fn rb_flag(x: u32) -> u32 {
4    1 << x
5}
6
7// FLAG_UNSAFE macro in harfbuzz.
8#[inline]
9pub fn rb_flag_unsafe(x: u32) -> u32 {
10    if x < 32 {
11        1 << x
12    } else {
13        0
14    }
15}
16
17// FLAG_RANGE macro in harfbuzz.
18#[inline]
19pub fn rb_flag_range(x: u32, y: u32) -> u32 {
20    (x < y) as u32 + rb_flag(y + 1) - rb_flag(x)
21}
22
23// FLAG64 macro in harfbuzz.
24#[inline]
25pub const fn rb_flag64(x: u32) -> u64 {
26    1 << x as u64
27}
28
29// FLAG64_UNSAFE macro in harfbuzz.
30#[inline]
31pub fn rb_flag64_unsafe(x: u32) -> u64 {
32    if x < 64 {
33        1 << (x as u64)
34    } else {
35        0
36    }
37}