equal
deleted
inserted
replaced
15 |
15 |
16 pub fn with_capacity(capacity: usize) -> Self { |
16 pub fn with_capacity(capacity: usize) -> Self { |
17 Self { |
17 Self { |
18 data: Vec::with_capacity(capacity), |
18 data: Vec::with_capacity(capacity), |
19 } |
19 } |
|
20 } |
|
21 |
|
22 pub fn get(&self, index: usize) -> Option<&T> { |
|
23 self.data[index].as_ref() |
|
24 } |
|
25 |
|
26 pub fn get_mut(&mut self, index: usize) -> Option<&mut T> { |
|
27 self.data[index].as_mut() |
20 } |
28 } |
21 |
29 |
22 pub fn insert(&mut self, index: usize, value: T) { |
30 pub fn insert(&mut self, index: usize, value: T) { |
23 if index >= self.data.len() { |
31 if index >= self.data.len() { |
24 self.data.reserve(index - self.data.len() + 1); |
32 self.data.reserve(index - self.data.len() + 1); |