-
-
Save d6y/6d0586d96fc64fdd0f16eaf31a27fafd to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Debuggable { | |
fn debug(self) -> Self; | |
} | |
impl<T> Debuggable for T | |
where | |
T: Sized + std::fmt::Debug, | |
{ | |
fn debug(self) -> Self { | |
dbg!(self) | |
} | |
} | |
fn main() { | |
let _x = "hello".debug(); | |
let _ys = (0..10) | |
.debug() | |
.map(|x| x * 3) | |
.collect::<Vec<usize>>() | |
.debug(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f40295c6954f5b612397ca199d991eaf
Output: