Cheatsheet: Data Structures
    Array / List
    Map / Dict
    Set
    Tuple
    Struct / Data Class
    Stacks
    Other Data Structures
    Collection Conversions
Cheatsheet: Control Flow
Cheatsheet: Class

Polyglot CheatSheet - Generics

Updated: 2021-11-19

Rust

// in function
fn foo<T>(list: &[T]) -> T {
}

// in struct
struct Point<T> {
    x: T,
    y: T,
}

// in enum
enum Option<T> {
    Some(T),
    None,
}

// in method
struct Point<T> {
    x: T,
    y: T,
}

impl<T> Point<T> {
    fn x(&self) -> &T {
        &self.x
    }
}

Java

Java Type erasure: enforcing type constraints only at compile time and discarding the element type information at runtime.