Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(const_generics)]
- use core::ptr::null_mut;
- #[derive(Clone, Copy, Debug)]
- #[repr(usize)]
- pub enum ArrayCount {
- Values3 = 3,
- Values4 = 4,
- Values6 = 6
- }
- /// Non-Copy type!
- #[repr(transparent)]
- struct ArrayItem<T>(*mut T);
- impl<T> ArrayItem<T> {
- pub fn new() -> Self {
- Self(null_mut())
- }
- }
- #[repr(transparent)]
- pub struct MyArray<T, const COUNT: ArrayCount>([ArrayItem<T>; COUNT as usize]);
- impl<T> MyArray<T, {ArrayCount::Values3}> {
- pub(crate) const fn new() -> Self {
- Self([
- ArrayItem::new(),
- ArrayItem::new(),
- ArrayItem::new(),
- ])
- }
- }
- fn main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement