nd_vector 0.1.0

[WIP] Lengthen! Shrink! Iterate! Scale! Twist and turn to your imagination along any dimension on a vector!
Documentation
use std::num::NonZeroUsize;

use serde::{Deserialize, Serialize};
use usage_types::full_shape::FullShape;

mod air;
pub use air::Air;
#[cfg(feature = "bevy")]
pub mod bevy;
#[cfg(feature = "bevy")]
pub use bevy::mesh::Transparent;
pub mod display;
pub mod prelude;
pub mod modify;
pub mod construct;
pub mod usage_types;
pub mod retrieve;

pub type DefinedShape = Vec<NonZeroUsize>;

/// ```text
/// ▣▦▥▩╱̅̅╲▜▄‾‾‾‾█╲▜█▀▀▀▀‾̅̅╲‾▄█▀▀▀▙╲▀▀▜▄▀▀‾̅̅╲‾▄█▀▀▀▙╲▜█▀▀▀▇‾╲
/// ▧◤  ╱╲╱╲ ▜▄  █ ╲▜█▀▀▀  ╲▜      ╲  ▜▄   ╲▜     █╲▜█▄▄▛  ╲
///     ╱╲╱╲╱╲__̲▜██__̲╲̲▜█▄▄▄▄_̲╲_̲▀▇▇▀_̲╲___̲▜▄__̲╲_̲▀▇▇▀_̲_̲╲̲▀█▄_̲▀▙_̲╲
///     ╲╱╲╱╲̲╱_̲╱_̲╱_̲╱_̲╱ ▟███▙ ╱▟███▙ ╱  ▟▛  ╱ ▟██▇▄  ̲╱_̲╱_̲╱_̲╱_╱
///      ╲╱╲̲╱_̲╱_̲╱_̲╱_̲╱ ▟▛ ▄▄ ╱▟█▄▄▛ ╱  ▟▛  ╱ ▟▛ ▟▛ ̲╱_̲╱_̲╱_̲╱_╱
///       ╲̲╱_̲╱_̲╱_̲╱_̲╱__̲▜██▛_̲╱▟█_̲▜▙╱__▟▛__̲╱_̲▟██▇▀̲▀__̲╱_̲╱_̲╱_̲╱_╱
/// 
/// ```

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VectorGrid<ItemType> {
    /// The defined shape of a VectorGrid,
    /// which is it's size along every axis, EXEPT FOR THE LAST ONE! The last axis is determined by the length of the vector.
    /// ```text
    ///      _________
    ///     ╱__╱__╱__╱╲ For example, lets say that we have this 3 x 1 x 2 block.
    ///    ╱__╱__╱__╱╲╱ As a VectorGrid, its defined shape would be [3, 1], and the vector's length, 6.
    ///  1 ╲__╲__╲__╲╱
    ///         3
    /// ```
    /// 
    defined_shape: DefinedShape,
    /// The vector of the VectorGrid! These are all the items in order.
    /// ```text
    /// This is what it looks like as a normal vector:
    /// ┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐
    /// │ #1 │ #2 │ #3 │ #4 │ #5 │ #6 │ #7 │ #8 │ #9 │ #10│ #11│ #12│ #13│ #14│
    /// └────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘
    /// 
    /// But with a defined shape of, lets say [4], then it would look like this:
    /// ┌────┬────┬────┬────┐
    /// │ #1 │ #2 │ #3 │ #4 │
    /// ├────┼────┼────┼────┤
    /// │ #5 │ #6 │ #7 │ #8 │
    /// ├────┼────┼────┼────┤
    /// │ #9 │ #10│ #11│ #12│
    /// ├────┼────┼────┴────┘
    /// │ #13│ #14│
    /// └────┴────┘
    /// ```
    items: Vec<ItemType>
}

impl<ItemType> VectorGrid<ItemType> {

    pub fn shape(&self) -> FullShape {
        FullShape { defined: self.defined_shape.clone(), total_length: self.items.len() }
    }

    pub fn defined_shape(&self) -> &DefinedShape {
        &self.defined_shape
    }

    pub fn defined_shape_usize(&self) -> Vec<usize> {
        self.defined_shape.iter().map(|v| {v.get()}).collect()
    }

    pub fn defined_shape_isize(&self) -> Vec<isize> {
        self.defined_shape.iter().map(|v| {v.get() as isize}).collect()
    }

    pub fn defined_shape_i32(&self) -> Vec<i32> {
        self.defined_shape.iter().map(|v| {v.get() as i32}).collect()
    }

    pub fn items(&self) -> &Vec<ItemType> {
        &self.items
    }
}