Skip to content

Latest commit

 

History

History
46 lines (41 loc) · 679 Bytes

hash-where-tuples-are-the-keys.md

File metadata and controls

46 lines (41 loc) · 679 Bytes
title timestamp author published description tags
Rust HashMap where tuples are the keys
2024-04-02 04:10:01 -0700
szabgab
true
A HashMap can have various things as key, for example tuples.
HashMap
tuple
insert

{% include file="examples/hash-of-tuples-as-keys/src/main.rs" %}

The third enty has the sam key as the first entry and thus the value replaces the old value.

{
    (
        "apple",
        "red",
    ): "23",
}

{
    (
        "apple",
        "red",
    ): "23",
    (
        "banana",
        "green",
    ): "3",
}

{
    (
        "apple",
        "red",
    ): "42",
    (
        "banana",
        "green",
    ): "3",
}