Created
November 19, 2014 18:55
-
-
Save jaredly/5fb209322945fd12f8a9 to your computer and use it in GitHub Desktop.
failing to be sized?
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 A { | |
fn one(&self); | |
} | |
trait B { | |
fn two(&self); | |
} | |
/** Dies because it wants the "Sized" trait | |
impl<'a> B for A + 'a { | |
fn two(&self) { | |
self.one() | |
} | |
} | |
<anon>:10:1: 14:2 error: the trait `core::kinds::Sized` is not implemented for the type `A+'a` | |
<anon>:10 impl<'a> B for A + 'a { | |
<anon>:11 fn two(&self) { | |
<anon>:12 self.one() | |
<anon>:13 } | |
<anon>:14 } | |
<anon>:10:1: 14:2 note: the trait `core::kinds::Sized` must be implemented because it is required by `B` | |
<anon>:10 impl<'a> B for A + 'a { | |
<anon>:11 fn two(&self) { | |
<anon>:12 self.one() | |
<anon>:13 } | |
<anon>:14 } | |
**/ | |
// this doesn't work for me, because B is defined in a different crate | |
impl<T: A> B for T { | |
fn two(&self) { | |
self.one() | |
} | |
} | |
fn main() { | |
println!("Hello, world!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment