MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / clear

Method clear

publication/code/chapter06/hashmap.rs:48–58  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

46 }
47
48 fn clear(&mut self) {
49 let mut slot = Vec::with_capacity(self.cap);
50 let mut data = Vec::with_capacity(self.cap);
51 for _i in 0..self.cap{
52 slot.push(0);
53 data.push(Default::default());
54 }
55
56 self.slot = slot;
57 self.data = data;
58 }
59
60 fn hash(&self, key: usize) -> usize {
61 key % self.cap

Callers 1

basicFunction · 0.45

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected