Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AoC fixes and additions #181

Merged
merged 2 commits into from
Dec 1, 2020
Merged

AoC fixes and additions #181

merged 2 commits into from
Dec 1, 2020

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Dec 1, 2020

  • Introduces ::std::collections w/ HashSet and HashMap
    collections.

These differ from what the anonymous object is capable of by using a
Key type similar to ConstValue.

This type gatekeeps values which cannot be used as a key in a hashed
collection, allowing for these collections to be used in situations
where complex keys are needed and not just strings.

use std::collections::HashMap;

enum Tile {
    Wall,
}

let m = HashMap::new();

m.insert((0, 1), Tile::Wall);

assert_eq!(m.get((0, 1)), Some(Tile::Wall));
assert_eq!(m.get((0, 2)), None);
  • Introduces a couple of utility functions (these will hopefully use
    generics in the future to avoid the type in the name):
    • String::is_empty.
    • String::split (char pattern monomorphization).
    • ::std::string::parse_int.
    • Vec::sort_int.

* Introduces `::std::collections` w/ `HashSet` and `HashMap`
  collections.

These differ from what the anonymous object is capable of by using a
`Key` type similar to `ConstValue`.

This type gatekeeps values which cannot be used as a key in a hashed
collection, allowing for these collections to be used in situations
where complex keys are needed and not just strings.

```rune
use std::collections::HashMap;

enum Tile {
    Wall,
}

let m = HashMap::new();

m.insert((0, 1), Tile::Wall);

assert_eq!(m.get((0, 1)), Some(Tile::Wall));
assert_eq!(m.get((0, 2)), None);
```

* Introduces a couple of utility functions (these will hopefully use
  generics in the future to avoid the type in the name):
  * `String::is_empty`.
  * `String::split` (char pattern monomorphization).
  * `::std::string::parse_int`.
  * `Vec::sort_int`.
@udoprog udoprog added the enhancement New feature or request label Dec 1, 2020
@udoprog udoprog merged commit 2179b48 into main Dec 1, 2020
@udoprog udoprog deleted the aoc-fixes branch December 1, 2020 08:21
@udoprog udoprog added the changelog Issue has been added to the changelog label Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant