[−][src]Struct gridly::vector::Vector
A measurement of distance between two Location
s
A Vector
is the measurement of distance between two
Location
s. It supports arithmetic operations with itself, as well
as anything which can be converted into a Vector. Currently, Rows
,
Columns
, and Direction
all have this property, as well as
(Rows, Columns)
, (Columns, Rows)
, and (isize, isize)
(which is treated as (Rows, Columns)
).
Fields
rows: Rows
columns: Columns
Implementations
impl Vector
[src]
#[must_use]pub fn new(rows: impl Into<Rows>, columns: impl Into<Columns>) -> Self
[src]
Create a new Vector
with the given rows
and columns
.
Example
use gridly::vector::*; assert_eq!( Vector::new(3, 4), Vector { rows: Rows(3), columns: Columns(4), }, );
#[must_use]pub const fn zero() -> Vector
[src]
#[must_use]pub const fn upward(size: isize) -> Vector
[src]
Create an upward pointing vector of the given size
use gridly::prelude::*; assert_eq!(Vector::upward(5), Vector::new(-5, 0))
#[must_use]pub const fn downward(size: isize) -> Vector
[src]
Create a downward pointing vector of the given size
use gridly::prelude::*; assert_eq!(Vector::downward(5), Vector::new(5, 0))
#[must_use]pub const fn leftward(size: isize) -> Vector
[src]
Create a leftward pointing vector of the given size
use gridly::prelude::*; assert_eq!(Vector::leftward(5), Vector::new(0, -5))
#[must_use]pub const fn rightward(size: isize) -> Vector
[src]
Create a rightward pointing vector of the given size
use gridly::prelude::*; assert_eq!(Vector::rightward(5), Vector::new(0, 5))
#[must_use]pub fn in_direction(direction: Direction, length: isize) -> Vector
[src]
Create a vector of the given size in the given direction
use gridly::prelude::*; assert_eq!(Vector::in_direction(Up, 10), Vector::new(-10, 0));
Trait Implementations
impl<T: VectorLike> Add<T> for Vector
[src]
type Output = Vector
The resulting type after applying the +
operator.
#[must_use]fn add(self, rhs: T) -> Vector
[src]
impl<T: VectorLike> AddAssign<T> for Vector
[src]
fn add_assign(&mut self, rhs: T)
[src]
impl Clone for Vector
[src]
impl Copy for Vector
[src]
impl Debug for Vector
[src]
impl Default for Vector
[src]
impl Eq for Vector
[src]
impl Hash for Vector
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Copy> Mul<T> for Vector where
isize: Mul<T, Output = isize>,
[src]
isize: Mul<T, Output = isize>,
Multiply a vector's components by a constant factor
type Output = Vector
The resulting type after applying the *
operator.
#[must_use]fn mul(self, factor: T) -> Vector
[src]
impl<T: Copy> MulAssign<T> for Vector where
isize: MulAssign<T>,
[src]
isize: MulAssign<T>,
Multiply a vector's components by a constant factor in-place
fn mul_assign(&mut self, factor: T)
[src]
impl Neg for Vector
[src]
type Output = Vector
The resulting type after applying the -
operator.
#[must_use]fn neg(self) -> Vector
[src]
impl<T: VectorLike> PartialEq<T> for Vector
[src]
impl<T: VectorLike> PartialOrd<T> for Vector
[src]
#[must_use]fn partial_cmp(&self, rhs: &T) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for Vector
[src]
impl<T: VectorLike> Sub<T> for Vector
[src]
type Output = Vector
The resulting type after applying the -
operator.
fn sub(self, rhs: T) -> Vector
[src]
impl<T: VectorLike> SubAssign<T> for Vector
[src]
fn sub_assign(&mut self, rhs: T)
[src]
impl<T: VectorLike> Sum<T> for Vector
[src]
impl VectorLike for Vector
[src]
#[must_use]fn rows(&self) -> Rows
[src]
#[must_use]fn columns(&self) -> Columns
[src]
#[must_use]fn as_vector(&self) -> Vector
[src]
#[must_use]fn manhattan_length(&self) -> isize
[src]
#[must_use]fn checked_manhattan_length(&self) -> Option<isize>
[src]
#[must_use]fn clockwise(&self) -> Vector
[src]
#[must_use]fn anticlockwise(&self) -> Vector
[src]
#[must_use]fn reverse(&self) -> Vector
[src]
#[must_use]fn rotate(&self, rotation: Rotation) -> Vector
[src]
#[must_use]fn get_component<T: Component>(&self) -> T
[src]
#[must_use]fn transpose(&self) -> Vector
[src]
#[must_use]fn direction(&self) -> Option<Direction>
[src]
Auto Trait Implementations
impl RefUnwindSafe for Vector
impl Send for Vector
impl Sync for Vector
impl Unpin for Vector
impl UnwindSafe for Vector
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,