Last active
August 29, 2015 13:55
-
-
Save DaGenix/8772910 to your computer and use it in GitHub Desktop.
Question about generic impls
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
trait SomeTrait { } | |
struct SomeStruct; | |
impl SomeTrait for SomeStruct { } | |
fn foo<T: SomeTrait>(_: T) { } | |
fn main() { | |
// This works fine | |
let x = SomeStruct; | |
foo(x); | |
// This fails with: error: failed to find an implementation of trait SomeTrait for &SomeStruct | |
let y = SomeStruct; | |
foo(&y); | |
// If I add this to the code: impl <'a> SomeTrait for &'a SomeStruct { } | |
// everything compiles. Is there some reason Rust can't derive that impl automatically? | |
// Is there a plan to have Rust automatically derive it in the future? Does this have | |
// something to do with DSTs? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment