// check-pass #![allow(incomplete_features)] use std::fmt::Debug; trait Foo { fn foo(&self) -> impl Debug; } impl Foo for () { fn foo(&self) -> impl Debug { "Hello, world" } } impl Foo for std::marker::PhantomData { fn foo(&self) -> impl Debug { T::default() } } trait Bar { fn bar(&self) -> impl Debug; } impl Bar for () { fn bar(&self) -> impl Debug { format!("Hello with generic {}", std::any::type_name::()) } } trait Baz { fn baz(&self) -> impl Debug + '_; } impl Baz for String { fn baz(&self) -> impl Debug + '_ { (self,) } } fn main() { println!("{:?}", ().foo()); println!("{:?}", ().bar::()); println!("{:?}", "hi".to_string().baz()); }