1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

use std::ops::Deref;
use std::ops::DerefMut;

#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum StaticInitErr {
	PrevLock,
	AllowLock,
	UnkState,
}

impl StaticInitErr {
	#[inline]
	pub const fn prev() -> Self {
		StaticInitErr::PrevLock
	}
	
	#[inline]
	pub const fn allow() -> Self {
		StaticInitErr::AllowLock
	}
	
	#[inline]
	pub const fn unk() -> Self {
		StaticInitErr::UnkState
	}
}


#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum IgnoreInitErr {
	PrevLock,
	AllowLock,
}

impl IgnoreInitErr {
	#[inline]
	pub const fn prev() -> Self {
		IgnoreInitErr::PrevLock
	}
	
	#[inline]
	pub const fn allow() -> Self {
		IgnoreInitErr::AllowLock	
	}
}



#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct StaticErr<T> {
	data:		T,
	r#type:	StaticInitErr,
}

impl<T> From<T> for StaticErr<T> {
	#[inline(always)]
	fn from(a: T) -> Self {
		Self::unk(a)
	}
}

impl<T> StaticErr<T> {
	#[inline]
	pub const fn new(arg: T, err: StaticInitErr) -> Self {
		Self {
			data:		arg,
			r#type:	err,
		}
	}
	
	#[inline]
	pub const fn prev(arg: T) -> Self {
		Self::new(arg, StaticInitErr::prev())
	}
	
	#[inline]
	pub const fn allow(arg: T) -> Self {
		Self::new(arg, StaticInitErr::allow())
	}
	
	#[inline]
	pub const fn unk(arg: T) -> Self {
		Self::new(arg, StaticInitErr::unk())
	}
	
	#[inline]
	pub fn into_inner(self) -> T {
		self.data
	}
	
	#[inline]
	pub fn into_type(self) -> StaticInitErr {
		self.r#type
	}
	
	#[inline(always)]
	pub const fn as_type(&self) -> &StaticInitErr {
		&self.r#type
	}
	
	#[inline(always)]
	pub const fn as_inner(&self) -> &T {
		&self.data
	}
}


impl<T> From<(T, StaticInitErr)> for StaticErr<T> {
	#[inline(always)]
	fn from((v, t): (T, StaticInitErr)) -> Self {
		Self::new(v, t)
	}
}

impl<T> Deref for StaticErr<T> {
	type Target = StaticInitErr;
	
	#[inline(always)]
	fn deref(&self) -> &Self::Target {
		&self.r#type
	}
}

impl<T> DerefMut for StaticErr<T> {
	#[inline(always)]
	fn deref_mut(&mut self) -> &mut Self::Target {
		&mut self.r#type
	}
}