Struct analog_literals::Cuboid [−][src]
pub struct Cuboid { pub w: usize, pub h: usize, pub l: usize, }
Expand description
A 3D Cuboid with a certain width, height, and length.
Example
Say you’re trying to solve the packing problem for fitting the largest number of dogecoin mining rigs in your 1.5 bedroom SF “apartment”. A 1x programmer would probably just use a couple of boring ’ol cOnStAnTs to define the length, width, and height of their dogecoin miners. Of course, you’re not a 10x programmer, so you use a 3D analog literal to visually represent the dimensions of your mining rigs:
const MINING_RIG: Cuboid = analog_literal! { +------------------------------------------+ / /| / / + / /**/ / / / /**/ / / / /**/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / +------------------------------------------+ / | /* -= dogecoin one =- */ /*(o)*/ |/ +------------------------------------------+ }; assert_eq!(MINING_RIG.w, 21); assert_eq!(MINING_RIG.h, 1); assert_eq!(MINING_RIG.l, 16);
Fields
w: usize
Width of the literal (counts how many --
wide the analog literal is)
h: usize
Height of the literal (counts how many |
tall the analog literal is)
l: usize
Length of the literal (counts how many /
deep the analog literal is)
Implementations
impl Cuboid
[src]
impl Cuboid
[src]pub const fn volume(&self) -> usize
[src]
pub const fn volume(&self) -> usize
[src]Return the volume of the cuboid.
Note that Cuboid
does not implement Eq
nor Ord
, as it would be
rude to assume that two literals are the same just because they are
rotationally transformed.
Just like Rectangle::area()
, the underlying implementation of this
method is highly complex and aggressively optimized. You could take a
look, but you’ll be hard pressed to make heads or tails of it. You’ve
been warned.
pub const fn top(&self) -> Rectangle
[src]
pub const fn top(&self) -> Rectangle
[src]Returns a Rectangle
with the same dimensions as the top of the
Cubiod.
Example
pub const CUBE_5_BY_2_BY_4: Cuboid = analog_literal! { +----------+ / /| / / | / / + / / / +----------+ / | | / | |/ +----------+ }; let top = analog_literal! { +----------+ | | | | | | | | +----------+ }; assert_eq!(CUBE_5_BY_2_BY_4.top().w, top.w); assert_eq!(CUBE_5_BY_2_BY_4.top().h, top.h);
pub const fn side(&self) -> Rectangle
[src]
pub const fn side(&self) -> Rectangle
[src]Returns a Rectangle
with the same dimensions as the side of the
Cubiod.
Example
pub const CUBE_5_BY_2_BY_4: Cuboid = analog_literal! { +----------+ / /| / / | / / + / / / +----------+ / | | / | |/ +----------+ }; let side = analog_literal! { +--------+ | | | | +--------+ }; assert_eq!(CUBE_5_BY_2_BY_4.side().w, side.w); assert_eq!(CUBE_5_BY_2_BY_4.side().h, side.h);
pub const fn front(&self) -> Rectangle
[src]
pub const fn front(&self) -> Rectangle
[src]Returns a Rectangle
with the same dimensions as the front of the
Cubiod.
Example
pub const CUBE_5_BY_2_BY_4: Cuboid = analog_literal! { +----------+ / /| / / | / / + / / / +----------+ / | | / | |/ +----------+ }; let front = analog_literal! { +----------+ | | | | +----------+ }; assert_eq!(CUBE_5_BY_2_BY_4.front().w, front.w); assert_eq!(CUBE_5_BY_2_BY_4.front().h, front.h);