vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Byte occurrence count operation module.

// Backend-specific lowering for byte count.



// CPU reference kernel for `buffer.byte_count`.

/// Count occurrences of `needle_byte & 0xff`.
#[must_use]
pub fn byte_count(haystack: &[u8], needle_byte: u32) -> u32 {
    let needle = (needle_byte & 0xff) as u8;
    haystack
        .iter()
        .filter(|&&byte| byte == needle)
        .fold(0_u32, |count, _| count.wrapping_add(1))
}