Skip to content

std::collections

Struct VecDeque

A double-ended queue implemented with a growable ring buffer. - ring buffer:circular buffer When you reach the end of the array, the next position wraps around to the start (index 0) which makes a loop, making it resemble a ring.

Struct HashMap

Enum Entry

use std::collections::HashMap;
fn main() {
  let mut letters = HashMap::new();
  for ch in "s gad ga".chars() {
    let y = letters.entry(ch).and_modify(|x| *x += 1).or_insert(1);
    println!("{}", y);
  }
}