Skip to content

Instantly share code, notes, and snippets.

@Limeth
Created June 9, 2016 06:10
Show Gist options
  • Select an option

  • Save Limeth/8e033e948de2ce07de256ca3815dfdf6 to your computer and use it in GitHub Desktop.

Select an option

Save Limeth/8e033e948de2ce07de256ca3815dfdf6 to your computer and use it in GitHub Desktop.
fn main() {
println!("Hello, world!");
}
trait BaseFloat {}
trait NumPoint<F: BaseFloat> {}
trait AbstractSurface<F: BaseFloat, P: NumPoint<F>> {}
trait Surface<F: BaseFloat, P: NumPoint<F>> {}
// I want to make anything that implements an AbstractSurface
// automatically inherit the functionality for Surface.
impl<F: BaseFloat, P: NumPoint<F>, A: AbstractSurface<F, P>>
Surface<F, P> for A {
}
// I also want to let users make their own implementation of
// Surface.
struct PerlinSurface3<F: BaseFloat>;
impl<F: BaseFloat, P: NumPoint<F>>
Surface<F, P> for PerlinSurface3<F> {
}
@Limeth

Limeth commented Jun 9, 2016

Copy link
Copy Markdown
Author

Compiling scratchpad v0.1.0 (file:///home/limeth/workspace/rust/scratchpad)
src/main.rs:19:1: 22:2 error: conflicting implementations of trait Surface<_, _> for type PerlinSurface3<_>: [E0119]
src/main.rs:19 impl<F: BaseFloat, P: NumPoint>
^
src/main.rs:19:1: 22:2 help: run rustc --explain E0119 to see a detailed explanation
src/main.rs:12:1: 14:2 note: conflicting implementation is here:
src/main.rs:12 impl<F: BaseFloat, P: NumPoint, A: AbstractSurface<F, P>>
^
error: aborting due to previous error
error: Could not compile scratchpad.

To learn more, run the command again with --verbose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment