// codesnip-guard: ArrayVec #[cfg_attr(any(),rustfmt::skip)]pub use self::array_vec::{ArrayVec,ToArrayVec,ToArrayVecScalar};#[cfg_attr(any(),rustfmt::skip)]mod array_vec{use std::ops::{Add,AddAssign,BitAnd,BitAndAssign,BitOr,BitOrAssign,BitXor,BitXorAssign,Div,DivAssign,Index,IndexMut,Mul,MulAssign,Neg,Not,Rem,RemAssign,Shl,ShlAssign,Shr,ShrAssign,Sub,SubAssign};#[derive(Clone,Copy,Debug,Default,PartialEq,Eq,PartialOrd,Ord,Hash)]pub struct ArrayVecScalar(pub T);implFromfor ArrayVecScalar{fn from(value:T)->Self{Self(value)}}pub trait ToArrayVecScalar:Sized{fn to_array_vec_scalar(self)->ArrayVecScalar;}implToArrayVecScalar for T{fn to_array_vec_scalar(self)->ArrayVecScalar{ArrayVecScalar(self)}}#[derive(Clone,Copy,Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]pub struct ArrayVec(pub[T;N]);pub trait ToArrayVec:Sized{fn to_array_vec(self)->ArrayVec;}implToArrayVecfor[T;N]{fn to_array_vec(self)->ArrayVec{ArrayVec(self)}}implDefault for ArrayVecwhere T:Default{fn default()->Self{Self(std::array::from_fn(|_|T::default()))}}implArrayVec{pub fn new(data:[T;N])->Self{Self(data)}pub fn map(&self,transform:impl FnMut(&T)->U)->ArrayVec{ArrayVec(array_from_iter(self.0 .iter().map(transform)))}pub fn zip_with(&self,other:&ArrayVec,mut combine:impl FnMut(&T,&U)->V)->ArrayVec{ArrayVec(array_from_iter(self.0 .iter().zip(other.0 .iter()).map(|(left,right)|combine(left,right))))}}implFrom<[T;N]>for ArrayVec{fn from(data:[T;N])->Self{Self(data)}}implFrom>for[T;N]{fn from(data:ArrayVec)->Self{data.0}}implAsRef<[T;N]>for ArrayVec{fn as_ref(&self)->&[T;N]{&self.0}}implAsMut<[T;N]>for ArrayVec{fn as_mut(&mut self)->&mut[T;N]{&mut self.0}}implIndexfor ArrayVec{type Output=T;fn index(&self,index:usize)->&Self::Output{&self.0[index]}}implIndexMutfor ArrayVec{fn index_mut(&mut self,index:usize)->&mut Self::Output{&mut self.0[index]}}#[inline]fn array_from_iter(mut iter:I)->[T;N]where I:Iterator{std::array::from_fn(|_|iter.next().unwrap())}macro_rules!impl_arrayvec_binop{($imp:ident,$method:ident,$op:tt)=>{impl$imp>for ArrayVecwhere T:$imp,{type Output=ArrayVec;fn$method(self,rhs:ArrayVec)->Self::Output{ArrayVec(array_from_iter(self.0 .into_iter().zip(rhs.0 .into_iter()).map(|(left_value,right_value)|left_value$op right_value),))}}impl$imp<&ArrayVec>for ArrayVecwhere T:$imp,U:Clone,{type Output=ArrayVec;fn$method(self,rhs:&ArrayVec)->Self::Output{$imp::$method(self,rhs.clone())}}impl$imp>for&ArrayVecwhere T:Clone+$imp,{type Output=ArrayVec;fn$method(self,rhs:ArrayVec)->Self::Output{$imp::$method(self.clone(),rhs)}}impl$imp<&ArrayVec>for&ArrayVecwhere T:Clone+$imp,U:Clone,{type Output=ArrayVec;fn$method(self,rhs:&ArrayVec)->Self::Output{$imp::$method(self.clone(),rhs.clone())}}impl$imp>for ArrayVecwhere T:$imp,U:Clone,{type Output=ArrayVec;fn$method(self,rhs:ArrayVecScalar)->Self::Output{let scalar_value=rhs.0;ArrayVec(array_from_iter(self.0 .into_iter().map(|value|value$op scalar_value.clone()),))}}impl$imp<&ArrayVecScalar>for ArrayVecwhere T:$imp,U:Clone,{type Output=ArrayVec;fn$method(self,rhs:&ArrayVecScalar)->Self::Output{$imp::$method(self,rhs.clone())}}impl$imp>for&ArrayVecwhere T:Clone+$imp,U:Clone,{type Output=ArrayVec;fn$method(self,rhs:ArrayVecScalar)->Self::Output{$imp::$method(self.clone(),rhs)}}impl$imp<&ArrayVecScalar>for&ArrayVecwhere T:Clone+$imp,U:Clone,{type Output=ArrayVec;fn$method(self,rhs:&ArrayVecScalar)->Self::Output{$imp::$method(self.clone(),rhs.clone())}}impl$imp>for ArrayVecScalarwhere U:Clone+$imp,{type Output=ArrayVec;fn$method(self,rhs:ArrayVec)->Self::Output{let scalar_value=self.0;ArrayVec(array_from_iter(rhs.0 .into_iter().map(|value|scalar_value.clone()$op value),))}}impl$imp<&ArrayVec>for ArrayVecScalarwhere U:Clone+$imp,T:Clone,{type Output=ArrayVec;fn$method(self,rhs:&ArrayVec)->Self::Output{$imp::$method(self,rhs.clone())}}impl$imp>for&ArrayVecScalarwhere U:Clone+$imp,{type Output=ArrayVec;fn$method(self,rhs:ArrayVec)->Self::Output{$imp::$method(self.clone(),rhs)}}impl$imp<&ArrayVec>for&ArrayVecScalarwhere U:Clone+$imp,T:Clone,{type Output=ArrayVec;fn$method(self,rhs:&ArrayVec)->Self::Output{$imp::$method(self.clone(),rhs.clone())}}};}macro_rules!impl_arrayvec_unop{($imp:ident,$method:ident,$op:tt)=>{impl$imp for ArrayVecwhere T:$imp,{type Output=ArrayVec;fn$method(self)->Self::Output{ArrayVec(array_from_iter(self.0 .into_iter().map(|value|$op value),))}}impl$imp for&ArrayVecwhere T:Clone+$imp,{type Output=ArrayVec;fn$method(self)->Self::Output{$imp::$method(self.clone())}}};}macro_rules!impl_arrayvec_assign{($imp:ident,$method:ident)=>{impl$imp>for ArrayVecwhere T:$imp,{fn$method(&mut self,rhs:ArrayVec){for(left_value,right_value)in self.0 .iter_mut().zip(rhs.0 .into_iter()){left_value.$method(right_value);}}}impl$imp<&ArrayVec>for ArrayVecwhere T:$imp,U:Clone,{fn$method(&mut self,rhs:&ArrayVec){for(left_value,right_value)in self.0 .iter_mut().zip(rhs.0 .iter()){left_value.$method(right_value.clone());}}}impl$imp>for ArrayVecwhere T:$imp,U:Clone,{fn$method(&mut self,rhs:ArrayVecScalar){let scalar_value=rhs.0;for value in self.0 .iter_mut(){value.$method(scalar_value.clone());}}}impl$imp<&ArrayVecScalar>for ArrayVecwhere T:$imp,U:Clone,{fn$method(&mut self,rhs:&ArrayVecScalar){self.$method(rhs.clone());}}};}impl_arrayvec_binop!(Add,add,+);impl_arrayvec_binop!(Sub,sub,-);impl_arrayvec_binop!(Mul,mul,*);impl_arrayvec_binop!(Div,div,/);impl_arrayvec_binop!(Rem,rem,%);impl_arrayvec_binop!(BitAnd,bitand,&);impl_arrayvec_binop!(BitOr,bitor,|);impl_arrayvec_binop!(BitXor,bitxor,^);impl_arrayvec_binop!(Shl,shl,<<);impl_arrayvec_binop!(Shr,shr,>>);impl_arrayvec_unop!(Neg,neg,-);impl_arrayvec_unop!(Not,not,!);impl_arrayvec_assign!(AddAssign,add_assign);impl_arrayvec_assign!(SubAssign,sub_assign);impl_arrayvec_assign!(MulAssign,mul_assign);impl_arrayvec_assign!(DivAssign,div_assign);impl_arrayvec_assign!(RemAssign,rem_assign);impl_arrayvec_assign!(BitAndAssign,bitand_assign);impl_arrayvec_assign!(BitOrAssign,bitor_assign);impl_arrayvec_assign!(BitXorAssign,bitxor_assign);impl_arrayvec_assign!(ShlAssign,shl_assign);impl_arrayvec_assign!(ShrAssign,shr_assign);}