In Rust, how can I fix the error, the "slash" core :: types :: Sized "is not implemented for the type" Object + "a`"

In the following code, I get a "flag core::kinds::Sizednot implemented for type error Object+'a". I disabled all other code that is not needed to cause an error.

fn main() {
}

pub trait Object {
    fn select(&mut self);
}

pub struct Ball<'a>;

impl<'a> Object for Ball<'a> {
    fn select(&mut self) {
        // Do something
    }
}

pub struct Foo<'a> {
    foo: Vec<Object + 'a>,
}

Playpen: http://is.gd/tjDxWl

Full error:

<anon>:15:1: 17:2 error: the trait `core::kinds::Sized` is not implemented for the type `Object+'a`
<anon>:15 pub struct Foo<'a> {
<anon>:16     foo: Vec<Object + 'a>,
<anon>:17 }
<anon>:15:1: 17:2 note: the trait `core::kinds::Sized` must be implemented because it is required by `collections::vec::Vec`
<anon>:15 pub struct Foo<'a> {
<anon>:16     foo: Vec<Object + 'a>,
<anon>:17 }
error: aborting due to previous error
playpen: application terminated with error code 101

I am very new to Rust and don't know where to go from here. Any suggestions?

+4
source share
1 answer

The main problem is as follows:

. : . - , , Ball, . ! , .

:

+4

All Articles