#![ doc = include_str!("../README.md")]
pub mod z2d;
pub mod z3d;
use core::error::Error;
use core::fmt::{Debug, Display, Formatter};
pub struct LookUpError{
coord: Vec<usize>,
bounds: Vec<usize>,
}
impl Debug for LookUpError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
return write!(f, "{{ file: {}, line: {}, coord: {}, bounds: {} }}", file!(), line!(), vec_to_string(&self.coord), vec_to_string(&self.bounds));
}
}
impl Display for LookUpError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
return write!(f, "Error: could not access coordinate {} because it is out of range for size {}", vec_to_string(&self.coord), vec_to_string(&self.bounds));
}
}
impl Error for LookUpError{}
impl LookUpError {
}
fn vec_to_string(v: &Vec<usize>) -> String{
let mut sb = String::from("(");
let mut not_first = false;
for n in v {
if not_first {
sb += &String::from(", ");
} else {
not_first = true;
}
sb += &String::from(n.to_string());
}
sb += &String::from(")");
return sb;
}