pub struct Change { /* private fields */ }Expand description
Represents a change for an event in the multilinear system.
Implementations§
Source§impl Change
impl Change
Sourcepub const fn condition(aspect: Aspect, value: usize) -> Self
pub const fn condition(aspect: Aspect, value: usize) -> Self
Creates a new condition change of the specified aspect with value.
Examples found in repository?
examples/example.rs (line 24)
6fn main() {
7 let mut story = MultilinearInfo::new();
8
9 // Create aspects
10 let place = story.add_aspect();
11 let clothes = story.add_aspect();
12
13 // Define event: Move from bedroom to living room
14 let event_move = story
15 .add_event()
16 .with_change(&[Change::transition(place, 0, 1)])
17 .unwrap()
18 .event();
19
20 // Define event: Change clothes in bedroom
21 let event_clothes = story
22 .add_event()
23 .with_change(&[
24 Change::condition(place, 0),
25 Change::transition(clothes, 1, 0),
26 ])
27 .unwrap()
28 .event();
29
30 let mut simulation = MultilinearSimulation::new(story);
31 simulation.try_call(event_clothes);
32 simulation.try_call(event_move);
33 simulation.try_revert(event_move);
34}Sourcepub const fn transition(aspect: Aspect, from: usize, to: usize) -> Self
pub const fn transition(aspect: Aspect, from: usize, to: usize) -> Self
Creates a new transition change of the specified aspect changing the value from from to to.
Examples found in repository?
examples/example.rs (line 16)
6fn main() {
7 let mut story = MultilinearInfo::new();
8
9 // Create aspects
10 let place = story.add_aspect();
11 let clothes = story.add_aspect();
12
13 // Define event: Move from bedroom to living room
14 let event_move = story
15 .add_event()
16 .with_change(&[Change::transition(place, 0, 1)])
17 .unwrap()
18 .event();
19
20 // Define event: Change clothes in bedroom
21 let event_clothes = story
22 .add_event()
23 .with_change(&[
24 Change::condition(place, 0),
25 Change::transition(clothes, 1, 0),
26 ])
27 .unwrap()
28 .event();
29
30 let mut simulation = MultilinearSimulation::new(story);
31 simulation.try_call(event_clothes);
32 simulation.try_call(event_move);
33 simulation.try_revert(event_move);
34}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Change
impl RefUnwindSafe for Change
impl Send for Change
impl Sync for Change
impl Unpin for Change
impl UnsafeUnpin for Change
impl UnwindSafe for Change
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more