vulkan_int/
lib.rs

1use
2    std::
3        {
4            ops::
5                {
6                    Add,
7                    Sub,
8                    Mul,
9                    Div
10                }
11        };
12
13pub
14    use
15        std::
16            ops::
17                Deref;
18
19mod macros;
20mod clamp;
21
22#[
23    cfg(
24        test
25    )
26]
27
28mod tests;
29    
30#[
31    derive(
32        Debug
33    )
34]
35
36#[
37    repr(
38        transparent
39    )
40]
41
42pub
43    struct VulkanInt {
44        value:
45            i8
46    }
47
48impl
49    VulkanInt {
50        fn new(
51            value:
52                isize
53        ) ->
54            VulkanInt {
55                VulkanInt {
56                    value:
57                        clamp::
58                            clamp(
59                                value,
60                                
61                                -54 ..= 54
62                            )
63                                as i8
64                }
65            }
66    }
67
68impl
69    Deref for
70        VulkanInt {
71            type Target =
72                i8;
73            
74            fn deref(
75                self:
76                    &VulkanInt
77            ) ->
78                &Self::Target {
79                    &self
80                        .value
81                }
82        }
83
84vulkan_int_operation_impl!(
85    Add, add, +
86);
87
88vulkan_int_operation_impl!(
89    Sub, sub, -
90);
91
92vulkan_int_operation_impl!(
93    Mul, mul, *
94);
95
96vulkan_int_operation_impl!(
97    Div, div, /
98);