macro_rules! define_id_array {
    ($table_name:ident, $id_type:ty, $data_type:ty, [ $($t:tt)* ]) => { ... };
}
Expand description

Defines a new constant IdArray with a concise syntax.

It is meant to be used by buses and subsystems to create a similar macro with their device id type already specified, i.e., with fewer parameters to the end user.

Examples

#![feature(const_trait_impl)]

#[derive(Copy, Clone)]
struct Id(u32);

// SAFETY: `ZERO` is all zeroes and `to_rawid` stores `offset` as the second element of the raw
// device id pair.
unsafe impl const RawDeviceId for Id {
    type RawType = (u64, isize);
    const ZERO: Self::RawType = (0, 0);
    fn to_rawid(&self, offset: isize) -> Self::RawType {
        (self.0 as u64 + 1, offset)
    }
}

define_id_array!(A1, Id, (), []);
define_id_array!(A2, Id, &'static [u8], [(Id(10), None)]);
define_id_array!(A3, Id, &'static [u8], [(Id(10), Some(b"id1")), ]);
define_id_array!(A4, Id, &'static [u8], [(Id(10), Some(b"id1")), (Id(20), Some(b"id2"))]);
define_id_array!(A5, Id, &'static [u8], [(Id(10), Some(b"id1")), (Id(20), Some(b"id2")), ]);
define_id_array!(A6, Id, &'static [u8], [(Id(10), None), (Id(20), Some(b"id2")), ]);
define_id_array!(A7, Id, &'static [u8], [(Id(10), Some(b"id1")), (Id(20), None), ]);
define_id_array!(A8, Id, &'static [u8], [(Id(10), None), (Id(20), None), ]);
This documentation is an old archive. Please see https://rust.docs.kernel.org instead.