chiark / gitweb /
W
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 May 2022 15:03:40 +0000 (16:03 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 May 2022 15:03:40 +0000 (16:03 +0100)
src/main.rs

index 44e85ebb79a72298d4ab336faf7c8210a7bdadda..7c5ed1195657de6981c59e88e7a0263efc9230ea 100644 (file)
@@ -1,5 +1,7 @@
 #![allow(dead_code)]
 
+use std::mem::MaybeUninit;
+
 trait Ish {
     const N: usize;
     const F: &'static [&'static str];
@@ -12,13 +14,13 @@ impl Ish for Inner {
     const F: &'static [&'static str] = &["i"];
 }
 
-const fn plus<const AN: usize, const BN: usize>(x: &'static [&'static str],
-                                    b: &'static [&'static str])
-    -> &'static [&'static str]
+const fn plus<const N: usize>
+(x: &'static [&'static str],
+ b: &'static [&'static str])
+ -> &'static [&'static str]
 {
-    const N: usize = AN + BN;
 //    unsafe {
-        static mut ary: [MaybeUninit<&'static str>; _] = [MaybeUninit::new_uninit(); N];
+        
 //    }
     panic!()
 }
@@ -26,13 +28,17 @@ const fn plus<const AN: usize, const BN: usize>(x: &'static [&'static str],
 struct Outer { o: usize, }
 impl Ish for Outer {
     const N: usize = Inner::N + 1;
-    const F: &'static [&'static str] = plus::<{Inner::N}, 1>(
-        Inner::F,
-        &["o"]
-    );
+    const F: &'static [&'static str] = {
+        static mut ARY: [MaybeUninit<&'static str>; Inner::N + 1] = [MaybeUninit::uninit(); Inner::N + 1];
+
+        plus::<{Inner::N + 1}>(
+            Inner::F,
+            &["o"]
+        )
+    };
 }
 
 fn main(){
     eprintln!("IF {:?}", Inner::F);
-    eprintln!("OF {:?}", Outer::F);
+//    eprintln!("OF {:?}", Outer::F);
 }