Lines Matching defs:T
57 pub struct RawIdArray<T: RawDeviceId, const N: usize> {
58 ids: [T::RawType; N],
59 sentinel: MaybeUninit<T::RawType>,
62 impl<T: RawDeviceId, const N: usize> RawIdArray<T, N> {
71 pub struct IdArray<T: RawDeviceId, U, const N: usize> {
72 raw_ids: RawIdArray<T, N>,
76 impl<T: RawDeviceId, U, const N: usize> IdArray<T, U, N> {
88 const unsafe fn build(ids: [(T, U); N], data_offset: Option<usize>) -> Self {
89 let mut raw_ids = [const { MaybeUninit::<T::RawType>::uninit() }; N];
94 // SAFETY: by the safety requirement of `RawDeviceId`, we're guaranteed that `T` is
135 pub const fn new_without_index(ids: [(T, U); N]) -> Self {
142 pub const fn raw_ids(&self) -> &RawIdArray<T, N> {
147 impl<T: RawDeviceId + RawDeviceIdIndex, U, const N: usize> IdArray<T, U, N> {
151 pub const fn new(ids: [(T, U); N]) -> Self {
153 // `T::DRIVER_DATA_OFFSET` is guaranteed to be the correct offset (in bytes) to
154 // a field within `T::RawType`.
155 unsafe { Self::build(ids, Some(T::DRIVER_DATA_OFFSET)) }
163 /// The purpose of this trait is to allow `&'static dyn IdArray<T, U>` to be in context when `N` in
165 pub trait IdTable<T: RawDeviceId, U> {
167 fn as_ptr(&self) -> *const T::RawType;
170 fn id(&self, index: usize) -> &T::RawType;
176 impl<T: RawDeviceId, U, const N: usize> IdTable<T, U> for IdArray<T, U, N> {
177 fn as_ptr(&self) -> *const T::RawType {
183 fn id(&self, index: usize) -> &T::RawType {