diff --git a/units/src/weight.rs b/units/src/weight.rs index c7fb19913..ecd50b804 100644 --- a/units/src/weight.rs +++ b/units/src/weight.rs @@ -48,7 +48,13 @@ impl Weight { pub const fn from_wu(wu: u64) -> Self { Weight(wu) } /// Constructs a new [`Weight`] from kilo weight units returning [`None`] if an overflow occurred. - pub fn from_kwu(wu: u64) -> Option { wu.checked_mul(1000).map(Weight) } + pub const fn from_kwu(wu: u64) -> Option { + // No `map()` in const context. + match wu.checked_mul(1000) { + Some(wu) => Some(Weight::from_wu(wu)), + None => None, + } + } /// Constructs a new [`Weight`] from virtual bytes, returning [`None`] if an overflow occurred. pub const fn from_vb(vb: u64) -> Option {