generated from tipragot/rust
Add utils for hexagonal grild #50
No reviewers
Labels
No labels
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Fix
Kind/Security
Kind/Testing
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: fish-cannard/border-wars#50
Loading…
Reference in a new issue
No description provided.
Delete branch "hex-utils"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add utils for hexagonal grildto WIP: Add utils for hexagonal grildWIP: Add utils for hexagonal grildto Add utils for hexagonal grild@ -0,0 +13,4 @@
/// R coordinate
pub r: i32,
}
I think we should be more generic over the type used. You can use the num crate to do so. And you could still make a specific type using the
type
keyword.@ -0,0 +53,4 @@
let dr = self.r - other.r;
// dz = |z1 - z2| where z = -q - r
let dz = self.q + self.r - other.q - other.r;
dz = -dq - dr
@ -0,0 +105,4 @@
impl<T: HexNumber> ops::AddAssign<Self> for HexPosition<T> {
fn add_assign(&mut self, other: Self) {
*self = *self + other;
Don't make a new allocation. Use the += operator
@ -0,0 +122,4 @@
impl<T: HexNumber> ops::SubAssign<Self> for HexPosition<T> {
fn sub_assign(&mut self, other: Self) {
*self = *self - other;
Don't make a new allocation. Use the += operator