Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(specialization)]
- use std::fmt::Debug;
- fn foo(v :impl Sized) -> impl Sized {
- #[derive(Debug)]
- struct T<I>(I);
- T(v)
- }
- fn main() {
- trait MaybeDebug {
- fn maybe_debug(&self);
- }
- impl<T> MaybeDebug for T {
- default fn maybe_debug(&self) {
- println!("Can't debug, sorry :(");
- }
- }
- impl<T: Debug> MaybeDebug for T {
- fn maybe_debug(&self) {
- println!("{:?}", self);
- }
- }
- foo(42).maybe_debug();
- struct NoDebug;
- foo(NoDebug).maybe_debug();
- }
Add Comment
Please, Sign In to add comment