Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- Io {
- out: "",
- err: "",
- }.out = "You can overload the assignment operator in Rust!";
- println!("{:p}", &std);
- std.out = "No, really! Check out the output of this program!";
- println!("{:p}", &std);
- std.err = "Warning: restrictions apply";
- }
- #[allow(non_upper_case_globals)]
- const std : Io = Io {
- out: "",
- err: "",
- };
- struct Io {
- out: &'static str,
- err: &'static str,
- }
- impl Drop for Io {
- fn drop(&mut self) {
- println!("{}", self.out);
- eprintln!("{}", self.err);
- }
- }
Add Comment
Please, Sign In to add comment