#![allow(unused_variables)]
#![allow(unused_imports)]
+use std::mem;
use std::mem::MaybeUninit;
type S = &'static str;
+
+#[repr(C)]
+struct Concat<const A: usize, const B: usize>(
+ [S; A],
+ [S; B],
+);
+
trait Ish { const N: usize; }
trait Has<const N: usize> {
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],
- <Inner as Has<{Inner::N}>>::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) }
};
}
*/
fn main(){
-// eprintln!("IF {:?}", Inner::F);
-// eprintln!("OF {:?}", Outer::F);
+ eprintln!("IF {:?}", Inner::F);
+ eprintln!("OF {:?}", Outer::F);
}