From 21ff3e9ba4ba532ae7490772a2d07e19f77d0e09 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 16 May 2022 16:24:53 +0100 Subject: [PATCH] W --- src/main.rs | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3e80125..de3f0a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,10 +2,18 @@ #![allow(unused_variables)] #![allow(unused_imports)] +use std::mem; use std::mem::MaybeUninit; type S = &'static str; + +#[repr(C)] +struct Concat( + [S; A], + [S; B], +); + trait Ish { const N: usize; } trait Has { @@ -21,18 +29,21 @@ impl Has<1> for Inner { const F: [S; 1] = ["i"]; } -struct Outer { o: usize, } +struct Outer { o: usize, p: usize } impl Ish for Outer { - const N: usize = Inner::N + 1; + const N: usize = Inner::N + 2; } -impl Has<{ Inner::N + 1 }> for Outer { - const F: [S; 2] = { - const TUPLE: ([S;1], [S; Inner::N]) = ( - ["i"; 1], - >::F, - ); - panic!() +impl Has<{ Inner::N + 2 }> for Outer { + const F: [S; Inner::N + 2] = { + const TUPLE: Concat< + 2, + { Inner::N }, + > = Concat( + ["o", "p"], + Inner::F, + ); + unsafe { mem::transmute(TUPLE) } }; } @@ -66,6 +77,6 @@ impl Ish for Outer { */ fn main(){ -// eprintln!("IF {:?}", Inner::F); -// eprintln!("OF {:?}", Outer::F); + eprintln!("IF {:?}", Inner::F); + eprintln!("OF {:?}", Outer::F); } -- 2.30.2