chiark / gitweb /
WRONG BOUNDS
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 19 Feb 2024 19:34:41 +0000 (19:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 19 Feb 2024 19:34:41 +0000 (19:34 +0000)
src/main.rs

index a552470e897a2c19c1e02358dadd58d130fe6b6c..ba14590d023afc61eda3463dbb8fc65f004ebae3 100644 (file)
@@ -1,28 +1,20 @@
 use educe::Educe;
-use std::fmt;
+use std::fmt::{self, Debug};
 
-#[derive(Debug)]
-pub struct Inner;
-
-impl Inner {
-    fn our_fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
-        Ok(())
-    }
+#[derive(Educe)]
+#[educe(Debug(bound = "X: Debug"))]
+pub struct Thing<X> {
+    #[educe(Debug(method = "no_fmt"))]
+    field: Box<X>,
 }
 
-#[derive(Educe)]
-#[educe(Debug(name = false))]
-pub struct Thing {
-    #[educe(Debug(method = "Inner::our_fmt"))]
-    field: Inner,
-    #[educe(Debug(name(Q)))]
-    other: u32,
+fn no_fmt<Q>(_: &Q, _f: &mut fmt::Formatter) -> fmt::Result {
+    Ok(())
 }
 
 fn main() {
     let a = Thing {
-        field: Inner,
-        other: 6,
+        field: Box::new(42),
     };
     println!("{:?}", &a);
 }