Vector of functions in Rust -
Vector of functions in Rust -
i learning rust , struggling lifetimes while creating simple observer store callback of arbitrary type.
i started basic struct
struct signal<t> { slots: vec<|t|> }
which got me initial lifetime error
signal_test.rs:7:16: 7:19 error: explicit lifetime bound required signal_test.rs:7 slots: vec<|t|> ^~~ error: aborting due previous error
so next seek adding lifetime specifiers.
struct signal<'r, t> { slots: vec<'r |t|> }
which gets me new errors
signal_test.rs:7:12: 7:23 error: wrong number of lifetime parameters: expected 0, found 1 [e0107] signal_test.rs:7 slots: vec<'r |t|> ^~~~~~~~~~~ signal_test.rs:7:19: 7:22 error: explicit lifetime bound required signal_test.rs:7 slots: vec<'r |t|>
i have not been able find plenty rust lifetime documentation hint @ need prepare this. not pattern utilize in rust. help , comments appreciated.
try using this:
struct signal<'r, t> { slots: vec<|t|: 'r> }
rust
Comments
Post a Comment