File: target_feature.rs

package info (click to toggle)
rust-bon 3.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 720 kB
  • sloc: makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#[cfg(target_arch = "x86_64")]
#[rustversion::since(1.86.0)]
mod msrv_1_86 {
    #![allow(dead_code)]
    use crate::prelude::*;

    #[test]
    fn target_feature_function() {
        #[builder]
        #[target_feature(enable = "avx2")]
        fn building_but_wider(_x: [u8; 32], _y: [u32; 8]) {}

        #[target_feature(enable = "avx2")]
        #[allow(unsafe_code)]
        unsafe fn wider() {
            building_but_wider().x([0; 32]).y([1; 8]).call();
        }
    }

    #[test]
    fn target_feature_method() {
        #[repr(C, align(32))]
        struct Brick([u8; 32]);
        struct Senti;

        #[bon]
        impl Senti {
            #[builder(finish_fn = yatta_but_wide)]
            #[target_feature(enable = "avx2")]
            fn new(brick: Brick) -> Self {
                let Brick(_) = brick;
                Self
            }
            #[target_feature(enable = "avx2")]
            #[allow(unsafe_code)]
            unsafe fn briiick() {
                Self::builder().brick(Brick([0; 32])).yatta_but_wide();
            }
        }
    }
}