Skip to content

Instantly share code, notes, and snippets.

@jaredly
Created November 19, 2014 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredly/5fb209322945fd12f8a9 to your computer and use it in GitHub Desktop.
Save jaredly/5fb209322945fd12f8a9 to your computer and use it in GitHub Desktop.
failing to be sized?
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