We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 56fe08a + 7759b24 commit 088d217Copy full SHA for 088d217
lib/runtime/src/table.rs
@@ -51,19 +51,10 @@ impl Table {
51
/// Returns `None` if table can't be grown by the specified amount
52
/// of elements.
53
pub fn grow(&self, delta: u32) -> Option<u32> {
54
- let new_len = match self.size().checked_add(delta) {
55
- Some(len) => {
56
- if let Some(max) = self.maximum {
57
- if len > max {
58
- return None;
59
- }
60
61
- len
62
63
- None => {
64
65
66
- };
+ let new_len = self.size().checked_add(delta)?;
+ if self.maximum.map_or(false, |max| new_len > max) {
+ return None;
+ }
67
self.vec.borrow_mut().resize(
68
usize::try_from(new_len).unwrap(),
69
VMCallerCheckedAnyfunc::default(),
0 commit comments