Change maxInt to return a comptime_int

This commit is contained in:
kayomn 2022-11-01 15:07:40 +00:00
parent ac95993a4b
commit f3426ef691
1 changed files with 1 additions and 1 deletions

View File

@ -4,7 +4,7 @@ pub const IntFittingRange = @import("std").math.IntFittingRange;
/// ///
/// Returns the maximum value of `Integer`. /// Returns the maximum value of `Integer`.
/// ///
pub fn maxInt(comptime Integer: type) Integer { pub fn maxInt(comptime Integer: type) comptime_int {
return switch (@typeInfo(Integer)) { return switch (@typeInfo(Integer)) {
.Int => |info| if (info.bits == 0) 0 else .Int => |info| if (info.bits == 0) 0 else
((1 << (info.bits - @boolToInt(info.signedness == .signed))) - 1), ((1 << (info.bits - @boolToInt(info.signedness == .signed))) - 1),