-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Credit goes to helix65535 (on the Rust Programming Language Community server)
This is code that does two different things depending purely on parenthetization:
use std::ops::{Sub, Neg};
struct Evil;
impl Sub<Evil> for () {
type Output = &'static str;
fn sub(self, _: Evil) -> &'static str {
"sub"
}
}
impl Neg for Evil {
type Output = &'static str;
fn neg(self) -> &'static str {
"neg"
}
}
fn main() {
println!("{}", {
loop { break; } - Evil
});
println!("{}", {(
loop { break; } - Evil
)});
}
it prints
neg
sub
Metadata
Metadata
Assignees
Labels
No labels