質問編集履歴

2

コード修正

2025/01/20 15:19

投稿

tt-44
tt-44

スコア2

test CHANGED
File without changes
test CHANGED
@@ -39,12 +39,12 @@
39
39
  stack.alloc(0, "v1");
40
40
  {
41
41
  let mut nest = stack.nest();
42
- nest.alloc(1, "v2");
42
+ nest.push(1, "v2");
43
43
  assert_eq!(nest.len(), 2);
44
44
  }
45
45
  assert_eq!(stack.len(), 1);
46
46
  stack.alloc(2, "v3");
47
- assert_eq!(stack.len(), 1);
47
+ assert_eq!(stack.len(), 2);
48
48
  }
49
49
  struct Memory<T> {
50
50
  data: HashMap<u32, T>,

1

コードのミスを修正

2025/01/20 10:20

投稿

tt-44
tt-44

スコア2

test CHANGED
File without changes
test CHANGED
@@ -102,6 +102,10 @@
102
102
  parent: Parent::Root(mem),
103
103
  }
104
104
  }
105
+ fn push(&mut self, id: u32, value: T){
106
+ self.ids.push(id);
107
+ self.alloc(id, value);
108
+ }
105
109
  fn alloc(&mut self, id: u32, value: T) {
106
110
  self.parent.alloc(id, value);
107
111
  }