pub struct Vec2Int {
    pub x: i32,
    pub y: i32,
}
Expand description

A set of 2 i32s representing a location or direction in the 2d plane.

Fields

x: i32

The x component of the vector.

y: i32

The y component of the vector.

Implementations

Creates a new Vec2 with the given x- and y-values.

It is often simpler, and preferred, to just write (x, y).into().

Gets the squared magnitude of the vector.

Useful for comparisons as it is faster to calculate than magnitude.

Gets the magnitude of the vector.

Gets the squared distance from this vector to rhs.

Useful for comparisons as it is faster to calculate than dist.

Gets the distance from this vector to rhs.

Casts this vector to a Vec2.

This uses as f32 under the hood, and as such comes with all the same unfortunate edge cases. Beware.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.