This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0599]: no method named `call_once` found for type `std::boxed::Box<dyn for<'r> std::boxed::FnBox<(&'r mut nphysics2d::world::World<f32>,), Output=()> + std::marker::Send>` in the current scope | |
--> src/physics_world_resource.rs:57:21 | |
| | |
57 | request.call_once(&mut self.world); | |
| ^^^^^^^^^ | |
| | |
= note: the method `call_once` exists but the following trait bounds were not satisfied: | |
`&std::boxed::Box<dyn for<'r> std::boxed::FnBox<(&'r mut nphysics2d::world::World<f32>,), Output=()> + std::marker::Send> : std::ops::FnOnce<_>` | |
`&mut std::boxed::Box<dyn for<'r> std::boxed::FnBox<(&'r mut nphysics2d::world::World<f32>,), Output=()> + std::marker::Send> : std::ops::FnOnce<_>` | |
`&dyn for<'r> std::boxed::FnBox<(&'r mut nphysics2d::world::World<f32>,), Output=()> + std::marker::Send : std::ops::FnOnce<_>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0161]: cannot move a value of type dyn for<'r> std::ops::FnOnce(&'r mut nphysics2d::world::World<f32>) + std::marker::Send: the size of dyn for<'r> std::ops::FnOnce(&'r mut nphysics2d::world::World<f32>) + std::marker::Send cannot be statically determined | |
--> src/physics_world_resource.rs:54:13 | |
| | |
54 | request(&mut self.world); | |
| ^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let vertexVector = rest | |
.windows(2) | |
.map(|vertices| { | |
let arr = [ | |
PosColor{ | |
position: [first[0], first[1], 0.0_f32], | |
color: color | |
}, | |
PosColor{ | |
position: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ops::Fn; | |
use automaton::Automaton; | |
pub struct StateMachine<'f, I: 'f, A: 'f, C: 'f> where C: Fn(&I)->(A, &'f C) | |
{ | |
current_state: &'f Fn(&I)->(A, &'f C) | |
} | |
impl <'f, I, A, C> StateMachine<'f, I, A, C> where C: Fn(&I)->(A, &'f C) { | |
pub fn new(init_state: &'f C) -> StateMachine<'f, I, A, C> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ops::{FnMut}; | |
pub trait Automaton<'f, I, A> { | |
fn transition(&'f mut self, input: &I) -> A; | |
} | |
impl<'f, I, A> Automaton<'f, I, A> for FnMut(&I) -> A { | |
fn transition(&'f mut self, input: &I) -> A { | |
self(&input) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub mod automaton; | |
pub mod state_machine; | |
pub mod move_state_machine; | |
#[cfg(test)] | |
mod tests { | |
use automaton::Automaton; | |
#[test] | |
fn fnmut_automaton_test() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ops::{FnMut}; | |
pub trait Automaton<'f, I, A> { | |
fn transition(&'f mut self, input: &I) -> A; | |
} | |
impl<'f, I, A> Automaton<'f, I, A> for FnMut(&I) -> A { | |
fn transition(&'f mut self, input: &I) -> A { | |
self(&input) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub mod automaton; | |
pub mod state_machine; | |
pub mod move_state_machine; | |
#[cfg(test)] | |
mod tests { | |
use automaton::Automaton; | |
#[test] | |
fn fnmut_automaton_test() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ops::FnOnce; | |
use automaton::Automaton; | |
use std::marker::PhantomData; | |
use std::mem::swap; | |
/// State machine implemented through a boxed consumable closure struct. Each | |
/// step, the currently boxed closure is called, returning an action and a | |
/// new boxed closure to call the next step. | |
pub struct OwnStateMachine<I, A, C: FnOnce(&I) -> (A, Box<C>)> { | |
current_state: Option<Box<C>>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! self_match { | |
($token:ident) => { | |
( & $token, & $token ) | |
} | |
} | |
macro_rules! jump_table_impl { | |
( | |
$name:ident : $fntype:ty { | |
$( $variant:ident = $value:expr ) ,* |