rust-lang / portable-simd

The testing ground for the future of portable SIMD in Rust
Apache License 2.0
903 stars 81 forks source link

fix simd_bitmask docs #378

Closed RalfJung closed 11 months ago

RalfJung commented 11 months ago

Seems like we forgot to update the docs when https://github.com/rust-lang/portable-simd/pull/267 landed. This documentation matches the follow testcase:

    let values = [false, false, false, true];
    let mask = Mask::<i64, 4>::from_array(values);

    unsafe {
        let bitmask1: u8 = simd_bitmask(mask.to_int());
        let bitmask2: [u8; 1] = simd_bitmask(mask.to_int());
        if cfg!(target_endian = "little") {
            assert_eq!(bitmask1, 0b1000);
            assert_eq!(bitmask2, [0b1000]);
        } else {
            assert_eq!(bitmask1, 0b0001);
            assert_eq!(bitmask2, [0b0001]);
        }
    }