use crate::*;
use super::istable::{IBitMask, IForbiddenValues};
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Padded<Left: Unsigned, T> {
pub lpad: Left::Padding,
pub value: T,
}
unsafe impl<Left: Unsigned, T: IStable> IStable for Padded<Left, T> {
type Size = Left::Add<T::Size>;
type Align = T::Align;
type ForbiddenValues = <T::ForbiddenValues as IForbiddenValues>::Shift<Left>;
type UnusedBits = <<Left::Padding as IStable>::UnusedBits as IBitMask>::BitOr<
<T::UnusedBits as IBitMask>::Shift<Left>,
>;
type HasExactlyOneNiche = Saturator;
type ContainsIndirections = T::ContainsIndirections;
const REPORT: &'static report::TypeReport = T::REPORT;
const ID: u64 = crate::report::gen_id(Self::REPORT);
}
impl<Left: Unsigned, T> From<T> for Padded<Left, T> {
fn from(value: T) -> Self {
Self {
lpad: Default::default(),
value,
}
}
}
impl<Left: Unsigned, T> core::ops::Deref for Padded<Left, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.value
}
}
impl<Left: Unsigned, T> core::ops::DerefMut for Padded<Left, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.value
}
}