pub struct GridEdge {
pub origin: Hex,
pub direction: EdgeDirection,
}
Expand description
Hexagonal grid orientated edge representation
Fields§
§origin: Hex
The coordinate of the edge
direction: EdgeDirection
The direction the edge points towards
Implementations§
Source§impl GridEdge
impl GridEdge
Sourcepub fn equivalent(&self, other: &GridEdge) -> bool
pub fn equivalent(&self, other: &GridEdge) -> bool
Edges are equivalent if they have identical or flipped origin or direction
Sourcepub const fn destination(&self) -> Hex
pub const fn destination(&self) -> Hex
Returns the coordinate the edge id pointing to
Sourcepub const fn vertices(&self) -> [GridVertex; 2]
pub const fn vertices(&self) -> [GridVertex; 2]
Returns the two vertices making this edge in clockwise order
Sourcepub const fn flipped(self) -> GridEdge
pub const fn flipped(self) -> GridEdge
Flips the edge, changing its origin
to be the destination
and
inverting its direction
Sourcepub const fn counter_clockwise(self) -> GridEdge
pub const fn counter_clockwise(self) -> GridEdge
Returns the next edge in counter clockwise order
Sourcepub const fn rotate_ccw(self, offset: u8) -> GridEdge
pub const fn rotate_ccw(self, offset: u8) -> GridEdge
Rotates self
counter clockwise by offset
amount.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GridEdge
impl<'de> Deserialize<'de> for GridEdge
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<GridEdge, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<GridEdge, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<EdgeDirection> for GridEdge
impl From<EdgeDirection> for GridEdge
Source§fn from(direction: EdgeDirection) -> GridEdge
fn from(direction: EdgeDirection) -> GridEdge
Converts to this type from the input type.
Source§impl Serialize for GridEdge
impl Serialize for GridEdge
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for GridEdge
impl Eq for GridEdge
impl StructuralPartialEq for GridEdge
Auto Trait Implementations§
impl Freeze for GridEdge
impl RefUnwindSafe for GridEdge
impl Send for GridEdge
impl Sync for GridEdge
impl Unpin for GridEdge
impl UnwindSafe for GridEdge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more