Comments (3)
Oh, no worries! That did solve my issue, thank you :)
from statig.
Adding a T: 'static
bound should do trick I think.
use statig::prelude::*;
use std::marker::PhantomData;
pub struct Event;
pub enum State<T> {
Init,
Other(PhantomData<T>),
}
impl<T> statig::State<Machine<T>> for State<T>
where
T: 'static, // Added bound here ...
{
fn call_handler(&mut self, machine: &mut Machine<T>, event: &Event) -> Response<Self> {
todo!()
}
}
#[derive(Default)]
pub struct Machine<T> {
_marker: PhantomData<T>,
}
impl<T> statig::StateMachine for Machine<T>
where
T: 'static, // ... and here.
{
type Event<'a> = Event;
type State = State<T>;
type Superstate<'a> = ();
const INITIAL: Self::State = State::Init;
}
fn main() {
let machine = Machine::<u32>::default().state_machine().init();
}
As far as I understand this tells the compiler that T
that can be safely held indefinitely long, including (but not necessarily) up until the end of the program. (link)
from statig.
Hi, just wanted to check back with you if you managed to solve your problem?
(I probably shouldn't have closed this issue before given you a chance to respond, sorry for that).
from statig.
Related Issues (16)
- Would be awesome to have an attribute that draws an ASCII picture of the resulting tree HOT 3
- Using multiple async state machines in parallel HOT 2
- Multiple refrences with different lifetimes as 'Context' HOT 3
- failed to resolve: could not find `awaitable` in `statig HOT 1
- Is it possible to split state machines across files? HOT 1
- Problem with using StateMachine as Bevy Component HOT 2
- Issue with context lifetimes HOT 5
- Add feature matrix support HOT 1
- Refactor async functionality for `no_std`/`no_alloc` HOT 5
- Support for nested initial transitions
- Allow async functions as state handler or actions HOT 5
- Accessing hardware peripherals from states HOT 2
- Add ability to derive traits on the final state machine HOT 2
- Allow generics to be used in the state machine HOT 5
- Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from statig.