| ... | @@ -3178,16 +3178,32 @@ pub const Alignment = enum(u6) { | ... | @@ -3178,16 +3178,32 @@ pub const Alignment = enum(u6) { |
| 3178 | } | 3178 | } |
| 3179 | | 3179 | |
| 3180 | /// Treats `none` as zero. | 3180 | /// Treats `none` as zero. |
| | 3181 | /// This matches previous behavior of using `@max` directly on byte units. |
| | 3182 | /// Prefer `maxStrict` if possible. |
| 3181 | pub fn max(lhs: Alignment, rhs: Alignment) Alignment { | 3183 | pub fn max(lhs: Alignment, rhs: Alignment) Alignment { |
| 3182 | if (lhs == .none) return rhs; | 3184 | if (lhs == .none) return rhs; |
| 3183 | if (rhs == .none) return lhs; | 3185 | if (rhs == .none) return lhs; |
| | 3186 | return maxStrict(lhs, rhs); |
| | 3187 | } |
| | 3188 | |
| | 3189 | pub fn maxStrict(lhs: Alignment, rhs: Alignment) Alignment { |
| | 3190 | assert(lhs != .none); |
| | 3191 | assert(rhs != .none); |
| 3184 | return @enumFromInt(@max(@intFromEnum(lhs), @intFromEnum(rhs))); | 3192 | return @enumFromInt(@max(@intFromEnum(lhs), @intFromEnum(rhs))); |
| 3185 | } | 3193 | } |
| 3186 | | 3194 | |
| 3187 | /// Treats `none` as maximum value. | 3195 | /// Treats `none` as zero. |
| | 3196 | /// This matches previous behavior of using `@min` directly on byte units. |
| | 3197 | /// Prefer `minStrict` if possible. |
| 3188 | pub fn min(lhs: Alignment, rhs: Alignment) Alignment { | 3198 | pub fn min(lhs: Alignment, rhs: Alignment) Alignment { |
| 3189 | if (lhs == .none) return rhs; | 3199 | if (lhs == .none) return lhs; |
| 3190 | if (rhs == .none) return lhs; | 3200 | if (rhs == .none) return rhs; |
| | 3201 | return minStrict(lhs, rhs); |
| | 3202 | } |
| | 3203 | |
| | 3204 | pub fn minStrict(lhs: Alignment, rhs: Alignment) Alignment { |
| | 3205 | assert(lhs != .none); |
| | 3206 | assert(rhs != .none); |
| 3191 | return @enumFromInt(@min(@intFromEnum(lhs), @intFromEnum(rhs))); | 3207 | return @enumFromInt(@min(@intFromEnum(lhs), @intFromEnum(rhs))); |
| 3192 | } | 3208 | } |
| 3193 | | 3209 | |