We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 73e33e5 commit 1db4b72Copy full SHA for 1db4b72
units/src/weight.rs
@@ -55,8 +55,12 @@ impl Weight {
55
pub fn from_kwu(wu: u64) -> Option<Self> { wu.checked_mul(1000).map(Weight) }
56
57
/// Constructs a new [`Weight`] from virtual bytes, returning [`None`] if an overflow occurred.
58
- pub fn from_vb(vb: u64) -> Option<Self> {
59
- vb.checked_mul(Self::WITNESS_SCALE_FACTOR).map(Weight::from_wu)
+ pub const fn from_vb(vb: u64) -> Option<Self> {
+ // No `map()` in const context.
60
+ match vb.checked_mul(Self::WITNESS_SCALE_FACTOR) {
61
+ Some(wu) => Some(Weight::from_wu(wu)),
62
+ None => None,
63
+ }
64
}
65
66
/// Constructs a new [`Weight`] from virtual bytes panicking if an overflow occurred.
0 commit comments