Skip to content

Instantly share code, notes, and snippets.

@jaredly

jaredly/ex.rs

Created Nov 19, 2014
Embed
What would you like to do?
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