-
-
Save tclh123/aaed683cd63fb9516695377778313a22 to your computer and use it in GitHub Desktop.
std::cout (C++) in Rust
This file contains 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
use std::ops::Shl; | |
struct Rsout; | |
struct Endl; | |
impl<'a> Shl<&'a str> for Rsout { | |
type Output = Rsout; | |
fn shl(self, _rhs: &'a str) -> Rsout { | |
print!("{}", _rhs); | |
self | |
} | |
} | |
impl Shl<i32> for Rsout { | |
type Output = Rsout; | |
fn shl(self, _rhs: i32) -> Rsout { | |
print!("{}", _rhs); | |
self | |
} | |
} | |
impl Shl<Endl> for Rsout { | |
type Output = Rsout; | |
fn shl(self, _rhs: Endl) -> Rsout { | |
print!("\n"); | |
self | |
} | |
} | |
fn main() { | |
Rsout << "Hello, " << "world!" << Endl; | |
Rsout << "1 + 2 = " << 1 + 2 << Endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment