(&self)
| 122 | } |
| 123 | |
| 124 | fn defun_pub_kernel(&self) { |
| 125 | let unit_amount = &self.ts.unit_amount; |
| 126 | let loop_unit_amount = &utils::pure_uint_list_to_ts(0..self.info.unit_amount); |
| 127 | let zero_padding = &utils::pure_uint_list_to_ts( |
| 128 | ::std::iter::repeat(0).take((self.info.unit_amount - 1) as usize), |
| 129 | ); |
| 130 | let one = quote!([1, #(#zero_padding),* ]); |
| 131 | let part = quote!( |
| 132 | /// Create a new fixed uint and value is zero. |
| 133 | #[inline] |
| 134 | pub const fn zero() -> Self { |
| 135 | Self::new([0; #unit_amount]) |
| 136 | } |
| 137 | /// Create a new fixed uint and value is one. |
| 138 | #[inline] |
| 139 | pub const fn one() -> Self { |
| 140 | Self::new( #one ) |
| 141 | } |
| 142 | /// Test if a fixed uint is zero. |
| 143 | #[inline] |
| 144 | pub fn is_zero(&self) -> bool { |
| 145 | let inner = self.inner(); |
| 146 | #({ |
| 147 | if inner[#loop_unit_amount] != 0 { |
| 148 | return false; |
| 149 | } |
| 150 | })* |
| 151 | true |
| 152 | } |
| 153 | /// Test if a fixed uint is the max value. |
| 154 | #[inline] |
| 155 | pub fn is_max(&self) -> bool { |
| 156 | let inner = self.inner(); |
| 157 | #({ |
| 158 | if inner[#loop_unit_amount] != !0 { |
| 159 | return false; |
| 160 | } |
| 161 | })* |
| 162 | true |
| 163 | } |
| 164 | ); |
| 165 | self.defun(part); |
| 166 | } |
| 167 | |
| 168 | fn deftrait_uint_convert(&self) { |
| 169 | let part = quote!( |
no test coverage detected