Created
June 14, 2021 15:43
-
-
Save DutchGhost/c501e259ecfa6e31cec6575b9ab7baaa to your computer and use it in GitHub Desktop.
std::cout << in Rust
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
| mod std { | |
| use std::ops::Shl; | |
| use std::fmt::Display; | |
| pub struct cout; | |
| impl<T: Display> Shl<T> for cout { | |
| type Output = cout; | |
| fn shl(self, data: T) -> cout { | |
| print!("{}", data); | |
| self | |
| } | |
| } | |
| pub struct endl; | |
| impl Display for endl { | |
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | |
| write!(f, "\n") | |
| } | |
| } | |
| } | |
| fn main() { | |
| std::cout << "hello world " << 420 << std::endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment