pub struct Vec2<T>(pub T, pub T);
Expand description
Simple two-dimensional vector of any numerical type. Supports only few mathematical operations as this is used mainly as data struct.
Tuple Fields§
§0: T
§1: T
Implementations§
source§impl<T> Vec2<T>
impl<T> Vec2<T>
sourcepub fn max(self, other: Self) -> Selfwhere
T: Ord,
pub fn max(self, other: Self) -> Selfwhere
T: Ord,
Returns the vector with the maximum of either coordinates.
sourcepub fn min(self, other: Self) -> Selfwhere
T: Ord,
pub fn min(self, other: Self) -> Selfwhere
T: Ord,
Returns the vector with the minimum of either coordinates.
sourcepub fn try_from<S>(value: Vec2<S>) -> Result<Self, T::Error>where
T: TryFrom<S>,
pub fn try_from<S>(value: Vec2<S>) -> Result<Self, T::Error>where
T: TryFrom<S>,
Try to convert all components of this vector to a new type, yielding either a vector of that new type, or an error.
sourcepub fn area(self) -> Twhere
T: Mul<T, Output = T>,
pub fn area(self) -> Twhere
T: Mul<T, Output = T>,
Seeing this vector as a dimension or size (width and height),
this returns the area that this dimensions contains (width * height
).
sourcepub fn flat_index_for_size(self, resolution: Vec2<T>) -> T
pub fn flat_index_for_size(self, resolution: Vec2<T>) -> T
Convert this two-dimensional coordinate to an index suited for one-dimensional flattened image arrays. Works for images that store the pixels row by row, one after another, in a single array. In debug mode, panics for an index out of bounds.
Trait Implementations§
impl<T: Copy> Copy for Vec2<T>
impl<T: Eq> Eq for Vec2<T>
impl<T> StructuralPartialEq for Vec2<T>
Auto Trait Implementations§
impl<T> Freeze for Vec2<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vec2<T>where
T: RefUnwindSafe,
impl<T> Send for Vec2<T>where
T: Send,
impl<T> Sync for Vec2<T>where
T: Sync,
impl<T> Unpin for Vec2<T>where
T: Unpin,
impl<T> UnwindSafe for Vec2<T>where
T: UnwindSafe,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.