From b9cda61f6d759f97151304f5ed9cf46ab32f2a5b Mon Sep 17 00:00:00 2001 From: Xiretza Date: Mon, 18 Dec 2023 18:22:48 +0000 Subject: [PATCH] common/rust: derive Enum for vec2::Direction --- Cargo.lock | 1 + common/rust/Cargo.toml | 1 + common/rust/src/vec2.rs | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index eff8c27..32005b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,6 +15,7 @@ dependencies = [ name = "aoc" version = "0.1.0" dependencies = [ + "enum-map", "num-traits", "strum 0.24.1", "thiserror", diff --git a/common/rust/Cargo.toml b/common/rust/Cargo.toml index ebe2750..96f2fee 100644 --- a/common/rust/Cargo.toml +++ b/common/rust/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +enum-map = "2.7.3" num-traits = "0.2.15" strum = { version = "0.24.1", features = ["derive"] } thiserror = "1.0.38" diff --git a/common/rust/src/vec2.rs b/common/rust/src/vec2.rs index f54c714..3f12bc4 100644 --- a/common/rust/src/vec2.rs +++ b/common/rust/src/vec2.rs @@ -4,6 +4,8 @@ use std::{ str::FromStr, }; +use enum_map::Enum; + #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Vec2 { pub x: i32, // increases toward right @@ -169,7 +171,7 @@ impl From for Vec2 { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Enum)] pub enum Direction { Up, Down,