Skip to content

Instantly share code, notes, and snippets.

@DutchGhost
Created June 14, 2021 15:43
Show Gist options
  • Select an option

  • Save DutchGhost/c501e259ecfa6e31cec6575b9ab7baaa to your computer and use it in GitHub Desktop.

Select an option

Save DutchGhost/c501e259ecfa6e31cec6575b9ab7baaa to your computer and use it in GitHub Desktop.
std::cout << in Rust
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