rust/hedgewars-server/src/core/indexslab.rs
changeset 15441 61a0bd0bb021
parent 15439 a158ff8f84ef
equal deleted inserted replaced
15440:96e438b114f0 15441:61a0bd0bb021
    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);