Std :: marker :: Size not satisfied

I am trying to create a kind of component system inspired by the reaction to the OpenGL project that I am working on. This system of components is defined by structures that contain some attributes and some functions. Like this:

pub struct Component<Lifecycle, PropType> {
    lifecycle: Lifecycle,
    props: PropType,
    children: Vec<Component<Lifecycle, PropType>>,
}

An example of a life cycle is as follows:

pub struct MeshLifecycle {
    render: (Fn(ComponentProps) -> Mesh),
}

An example PropType is as follows:

pub struct ComponentProps {
    position: Vertex,
}

Now this leads to some errors. Firstly:

the trait bound `std::ops::Fn(ComponentProps) -> Mesh + 'static: std::marker::Sized`

After some digging, I suggest that I should apply ?Sizedto types that contain functions in essence. Thus, the definition Componentnow reads:

pub struct Component<Lifecycle: ?Sized, PropType> {

This partly helps, but it misses me. Here is the complete compiler error:

src/main.rs:10:5: 10:25 error: the trait bound `Lifecycle: std::marker::Sized` is not satisfied [E0277]
src/main.rs:10     lifecycle: Lifecycle,
                   ^~~~~~~~~~~~~~~~~~~~
src/main.rs:10:5: 10:25 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:10:5: 10:25 help: consider adding a `where Lifecycle: std::marker::Sized` bound
src/main.rs:10:5: 10:25 note: only the last field of a struct or enum variant may have a dynamically sized type

- ( ), "" ? - , , , "VTable". , , , , .

+4

All Articles