error_union 0.2.0

A library to simplify error handling in Rust
Documentation
use crate::internal::*;

use const_panic::PanicVal;

const MAX_MESSAGE : usize = 100;
pub struct Message
{
    pub index : usize,
    pub message : [PanicVal<'static>; MAX_MESSAGE],
}

impl Message
{
    pub const fn append_str(mut self, data : &'static str) -> Self
    {
        if self.index != MAX_MESSAGE //Once we go beyond the max length we just stop
        {
            self.message[self.index] = PanicVal::write_str(data);
            self.index += 1;
            if self.index == MAX_MESSAGE - 1
            {
                self.message[self.index] = PanicVal::write_str("...");
                self.index = MAX_MESSAGE;
            }
        }
        self
    }
    pub const fn append_error_set(mut self, error_set: ErrorSet) -> Self
    {
        
        let mut i = 0;
        while i < error_set.length
        {
            self = self.append_str(error_set.types[i].type_name);
            
            if error_set.length >= 2 && i < error_set.length - 2
            {
                self = self.append_str(", ");
            } else if i < error_set.length - 1 {
                self = self.append_str(" and ");
            }
            i += 1;
        }
        self
    }
    pub const fn new() -> Self
    {
        Self {index : 0, message : [PanicVal::EMPTY; 100]}
    }
}