// Copyright 2025 Gabriel Bjørnager Jensen.

mod test;

/// Performs bitwise or where both sides are each other disjoint.
pub trait DisjointBitOr<Rhs = Self> {
	type Output;

	unsafe fn disjoint_bitor(self, rhs: Rhs) -> Self::Output;
}

macro_rules! impl_disjoint_bitor {
	{ $($Ty:ty),*$(,)? } => {$(
		impl ::multitype::DisjointBitOr for $Ty {
			type Output = Self;

			#[inline(always)]
			#[track_caller]
			unsafe fn disjoint_bitor(self, rhs: Self) -> Self::Output {
				unsafe { ::core::hint::assert_unchecked(self & rhs == Self::default()) };

				self | rhs
			}
		}
	)*};
}

impl_disjoint_bitor! {
	u8,
	u16,
	u32,
	u64,
	u128,
	usize,

	i8,
	i16,
	i32,
	i64,
	i128,
	isize,

	bool,
}
