common/rust: derive Enum for vec2::Direction
This commit is contained in:
parent
839b787de2
commit
b9cda61f6d
3 changed files with 5 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -15,6 +15,7 @@ dependencies = [
|
||||||
name = "aoc"
|
name = "aoc"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"enum-map",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"strum 0.24.1",
|
"strum 0.24.1",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
enum-map = "2.7.3"
|
||||||
num-traits = "0.2.15"
|
num-traits = "0.2.15"
|
||||||
strum = { version = "0.24.1", features = ["derive"] }
|
strum = { version = "0.24.1", features = ["derive"] }
|
||||||
thiserror = "1.0.38"
|
thiserror = "1.0.38"
|
||||||
|
|
|
@ -4,6 +4,8 @@ use std::{
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use enum_map::Enum;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Vec2 {
|
pub struct Vec2 {
|
||||||
pub x: i32, // increases toward right
|
pub x: i32, // increases toward right
|
||||||
|
@ -169,7 +171,7 @@ impl From<Direction> for Vec2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Enum)]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
|
|
Loading…
Reference in a new issue