Skip to content

Instantly share code, notes, and snippets.

@szeiger
Created September 27, 2017 22:49
Show Gist options
  • Save szeiger/93e4239ae544d8d98521e5c4ed7f146d to your computer and use it in GitHub Desktop.
Save szeiger/93e4239ae544d8d98521e5c4ed7f146d to your computer and use it in GitHub Desktop.
use std::ops::Add;
struct Point<T, U> { x: T, y: U }
impl<T : Add<Output=T>> Point<T, T> {
fn f(self) -> T { self.x + self.y }
}
fn main() {
Point { x: 1, y: 2.0 }.f();
// error[E0599]: no method named `f` found for type `Point<{integer}, {float}>` in the current scope
// --> src\main.rs:10:28
// |
// 10 | Point { x: 1, y: 2.0 }.f();
// | ^
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment