Skip to main content

Extent

Struct Extent 

Source
#[repr(transparent)]
pub struct Extent<T, const D: usize> { pub dim: [T; D], }
Expand description

๐Ÿ“ An orthogonal extension in D-space without a coordinate position.


๐Ÿ“geom/metric


Represents the lengths of each dimension in a multi-dimensional space, providing an origin-agnostic shape with the implied form of an orthotope (generalized rectangle or box).

See also Extent1, Extent2, Extent3.

Fieldsยง

ยงdim: [T; D]

The size values in D-dimensional space.

Implementationsยง

Sourceยง

impl<T, const D: usize> Extent<T, D>

Source

pub const fn new(dimensions: [T; D]) -> Self

Constructs a new Extent from the given dimensions.

Source

pub const fn as_slice(&self) -> &[T]

Returns a shared reference to the extent as a slice.

Source

pub const fn as_slice_mut(&mut self) -> &mut [T]

Returns an exclusive reference to the extent as a slice.

Source

pub fn is_uniform_nd(&self) -> bool
where T: PartialEq,

Returns true if all dimensions of the extent are equal. Returns true if all dimensions of the extent are equal.

Sourceยง

impl<T> Extent<T, 2>

Source

pub const fn x(self) -> T
where T: Copy,

Returns a copy of the first dimension x.

Source

pub const fn y(self) -> T
where T: Copy,

Returns a copy of the second dimension y.

Source

pub fn is_uniform(&self) -> bool
where T: PartialEq,

Returns true if the 2 dimensions are equal.

Sourceยง

impl<T> Extent<T, 3>

Source

pub const fn x(self) -> T
where T: Copy,

Returns a copy of the first dimension x.

Source

pub const fn y(self) -> T
where T: Copy,

Returns a copy of the second dimension y.

Source

pub const fn z(self) -> T
where T: Copy,

Returns a copy of the third dimension z.

Source

pub fn is_uniform_3d(&self) -> bool
where T: PartialEq,

Returns true if the 3 dimensions are equal.

Sourceยง

impl<const D: usize> Extent<i8, D>

Source

pub const fn measure(self) -> i8

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> i8

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<i8, 2>

Source

pub const fn area(self) -> i8

The area of the 2d extent.

Source

pub const fn perimeter(self) -> i8

The perimeter of the 2d extent.

Sourceยง

impl Extent<i8, 3>

Source

pub const fn volume(self) -> i8

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> i8

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<i16, D>

Source

pub const fn measure(self) -> i16

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> i16

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<i16, 2>

Source

pub const fn area(self) -> i16

The area of the 2d extent.

Source

pub const fn perimeter(self) -> i16

The perimeter of the 2d extent.

Sourceยง

impl Extent<i16, 3>

Source

pub const fn volume(self) -> i16

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> i16

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<i32, D>

Source

pub const fn measure(self) -> i32

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> i32

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<i32, 2>

Source

pub const fn area(self) -> i32

The area of the 2d extent.

Source

pub const fn perimeter(self) -> i32

The perimeter of the 2d extent.

Sourceยง

impl Extent<i32, 3>

Source

pub const fn volume(self) -> i32

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> i32

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<i64, D>

Source

pub const fn measure(self) -> i64

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> i64

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<i64, 2>

Source

pub const fn area(self) -> i64

The area of the 2d extent.

Source

pub const fn perimeter(self) -> i64

The perimeter of the 2d extent.

Sourceยง

impl Extent<i64, 3>

Source

pub const fn volume(self) -> i64

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> i64

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<i128, D>

Source

pub const fn measure(self) -> i128

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> i128

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<i128, 2>

Source

pub const fn area(self) -> i128

The area of the 2d extent.

Source

pub const fn perimeter(self) -> i128

The perimeter of the 2d extent.

Sourceยง

impl Extent<i128, 3>

Source

pub const fn volume(self) -> i128

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> i128

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<isize, D>

Source

pub const fn measure(self) -> isize

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> isize

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<isize, 2>

Source

pub const fn area(self) -> isize

The area of the 2d extent.

Source

pub const fn perimeter(self) -> isize

The perimeter of the 2d extent.

Sourceยง

impl Extent<isize, 3>

Source

pub const fn volume(self) -> isize

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> isize

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<u8, D>

Source

pub const fn measure(self) -> u8

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> u8

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<u8, 2>

Source

pub const fn area(self) -> u8

The area of the 2d extent.

Source

pub const fn perimeter(self) -> u8

The perimeter of the 2d extent.

Sourceยง

impl Extent<u8, 3>

Source

pub const fn volume(self) -> u8

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> u8

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<u16, D>

Source

pub const fn measure(self) -> u16

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> u16

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<u16, 2>

Source

pub const fn area(self) -> u16

The area of the 2d extent.

Source

pub const fn perimeter(self) -> u16

The perimeter of the 2d extent.

Sourceยง

impl Extent<u16, 3>

Source

pub const fn volume(self) -> u16

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> u16

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<u32, D>

Source

pub const fn measure(self) -> u32

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> u32

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<u32, 2>

Source

pub const fn area(self) -> u32

The area of the 2d extent.

Source

pub const fn perimeter(self) -> u32

The perimeter of the 2d extent.

Sourceยง

impl Extent<u32, 3>

Source

pub const fn volume(self) -> u32

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> u32

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<u64, D>

Source

pub const fn measure(self) -> u64

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> u64

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<u64, 2>

Source

pub const fn area(self) -> u64

The area of the 2d extent.

Source

pub const fn perimeter(self) -> u64

The perimeter of the 2d extent.

Sourceยง

impl Extent<u64, 3>

Source

pub const fn volume(self) -> u64

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> u64

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<u128, D>

Source

pub const fn measure(self) -> u128

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> u128

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<u128, 2>

Source

pub const fn area(self) -> u128

The area of the 2d extent.

Source

pub const fn perimeter(self) -> u128

The perimeter of the 2d extent.

Sourceยง

impl Extent<u128, 3>

Source

pub const fn volume(self) -> u128

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> u128

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<usize, D>

Source

pub const fn measure(self) -> usize

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> usize

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<usize, 2>

Source

pub const fn area(self) -> usize

The area of the 2d extent.

Source

pub const fn perimeter(self) -> usize

The perimeter of the 2d extent.

Sourceยง

impl Extent<usize, 3>

Source

pub const fn volume(self) -> usize

The volume of the 3d extent.

Source

pub const fn surface_area(self) -> usize

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<f32, D>

Source

pub const fn measure(self) -> f32

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> f32

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<f32, 2>

Source

pub const fn area(self) -> f32

Returns the area of the 2d extent.

Source

pub const fn perimeter(self) -> f32

Returns the perimeter of the 2d extent.

Sourceยง

impl Extent<f32, 3>

Source

pub const fn volume(self) -> f32

Returns the volume of the 3d extent.

Source

pub const fn surface_area(self) -> f32

The surface area of the 3d extent.

Sourceยง

impl<const D: usize> Extent<f64, D>

Source

pub const fn measure(self) -> f64

Returns the internal measure, the product of the extents.

Itโ€™s equivalent to length, area, and volume in 1, 2 and 3 dimensions.

Source

pub const fn boundary(self) -> f64

Returns the external boundary, the sum of the extents.

Itโ€™s equivalent to 2, perimeter and surface area in 1, 2 and 3 dimensions.

Sourceยง

impl Extent<f64, 2>

Source

pub const fn area(self) -> f64

Returns the area of the 2d extent.

Source

pub const fn perimeter(self) -> f64

Returns the perimeter of the 2d extent.

Sourceยง

impl Extent<f64, 3>

Source

pub const fn volume(self) -> f64

Returns the volume of the 3d extent.

Source

pub const fn surface_area(self) -> f64

The surface area of the 3d extent.

Sourceยง

impl<T: Copy> Extent<T, 1>

1D accessors

Source

pub const fn length(self) -> T

Returns a copy of the first dimension.

Source

pub const fn l(self) -> T

Returns a copy of the first dimension.

Sourceยง

impl<T: Copy> Extent<T, 2>

2D Accessors

Source

pub const fn width(self) -> T

Returns a copy of the horizontal dimension (X-axis).

Source

pub const fn w(self) -> T

Returns a copy of the horizontal dimension (X-axis).

Source

pub const fn height(self) -> T

Returns a copy of the vertical dimension (Y-axis).

Source

pub const fn h(self) -> T

Returns a copy of the vertical dimension (Y-axis).

Source

pub const fn length(self) -> T

Returns a copy of the horizontal dimension (X-axis) (width).

Source

pub const fn l(self) -> T

Returns a copy of the horizontal dimension (X-axis) (width).

Source

pub const fn breadth(self) -> T

Returns a copy of the vertical dimension (Y-axis) (width).

Source

pub const fn b(self) -> T

Returns a copy of the vertical dimension (Y-axis) (width).

Sourceยง

impl<T: Copy> Extent<T, 3>

3D Accessors

Source

pub const fn width(self) -> T

Returns a copy of the horizontal dimension (X-axis) (width).

Source

pub const fn w(self) -> T

Returns a copy of the horizontal dimension (X-axis) (width).

Source

pub const fn height(self) -> T

Returns a copy of the vertical dimension (Y-axis).

Source

pub const fn h(self) -> T

Returns a copy of the vertical dimension (Y-axis).

Source

pub const fn depth(self) -> T

Returns a copy of the depth dimension (Z-axis).

Source

pub const fn d(self) -> T

Returns a copy of the depth dimension (Z-axis).

Trait Implementationsยง

Sourceยง

impl<T: Clone, const D: usize> Clone for Extent<T, D>

Sourceยง

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl<T: ConstInitCore, const D: usize> ConstInitCore for Extent<T, D>

Sourceยง

const INIT: Self

Returns the compile-time โ€œinitial valueโ€ for a type.
Sourceยง

impl<T: Copy, const D: usize> Copy for Extent<T, D>

Sourceยง

impl<T: Debug, const D: usize> Debug for Extent<T, D>

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult<()>

Formats the value using the given formatter. Read more
Sourceยง

impl<T: Default, const D: usize> Default for Extent<T, D>

Sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl<T: Display, const D: usize> Display for Extent<T, D>

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult<()>

Formats the value using the given formatter. Read more
Sourceยง

impl<T: Eq, const D: usize> Eq for Extent<T, D>

Sourceยง

impl<T> From<(T, T)> for Extent<T, 2>

Sourceยง

fn from(dim: (T, T)) -> Self

Converts to this type from the input type.
Sourceยง

impl<T> From<(T, T, T)> for Extent<T, 3>

Sourceยง

fn from(dim: (T, T, T)) -> Self

Converts to this type from the input type.
Sourceยง

impl<T> From<(T, T, T, T)> for Extent<T, 4>

Sourceยง

fn from(dim: (T, T, T, T)) -> Self

Converts to this type from the input type.
Sourceยง

impl<T, const D: usize> From<[T; D]> for Extent<T, D>

Sourceยง

fn from(dim: [T; D]) -> Self

Converts to this type from the input type.
Sourceยง

impl<T: Hash, const D: usize> Hash for Extent<T, D>

Sourceยง

fn hash<HR: Hasher>(&self, state: &mut HR)

Feeds this value into the given Hasher. Read more
1.3.0 ยท Sourceยง

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl<T: Ord, const D: usize> Ord for Extent<T, D>

Sourceยง

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) ยท Sourceยง

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) ยท Sourceยง

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) ยท Sourceยง

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Sourceยง

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

๐Ÿ”ฌThis is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Sourceยง

impl<T: PartialEq, const D: usize> PartialEq for Extent<T, D>

Sourceยง

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Sourceยง

impl<T: PartialOrd, const D: usize> PartialOrd for Extent<T, D>

Sourceยง

fn partial_cmp(&self, other: &Self) -> Option<Ordering> โ“˜

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementationsยง

ยง

impl<T, const D: usize> Freeze for Extent<T, D>
where [T; D]: Freeze,

ยง

impl<T, const D: usize> RefUnwindSafe for Extent<T, D>

ยง

impl<T, const D: usize> Send for Extent<T, D>
where [T; D]: Send,

ยง

impl<T, const D: usize> Sync for Extent<T, D>
where [T; D]: Sync,

ยง

impl<T, const D: usize> Unpin for Extent<T, D>
where [T; D]: Unpin,

ยง

impl<T, const D: usize> UnsafeUnpin for Extent<T, D>

ยง

impl<T, const D: usize> UnwindSafe for Extent<T, D>

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> ByteSized for T

Sourceยง

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Sourceยง

const BYTE_SIZE: usize = _

The size of this type in bytes.
Sourceยง

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Sourceยง

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Sourceยง

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Hook for T

Sourceยง

fn hook<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Hooks a mutation step into the value and returns it. Read more
Sourceยง

fn tap<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Taps into the value for observation and returns it unchanged. Read more
Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

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

Sourceยง

impl<T, R> Morph<R> for T
where T: ?Sized,

Sourceยง

fn morph<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Morphs the value into a new one and returns it. Read more
Sourceยง

fn morph_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Morphs the value by shared reference and returns the result. Read more
Sourceยง

fn morph_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Morphs the value by exclusive reference and returns the result. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = !

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, !> โ“˜

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> โ“˜

Performs the conversion.