[−][src]Struct weasel::event::Conditional
Decorator for event triggers to add a condition on the generated event prototype.
Examples
use weasel::{ battle_rules, event::Conditional, event::DummyEvent, rules::empty::*, Battle, BattleRules, BattleState, EventTrigger, Server, WeaselError, }; battle_rules! {} let battle = Battle::builder(CustomRules::new()).build(); let mut server = Server::builder(battle).build(); let result = Conditional::new( DummyEvent::trigger(&mut server), std::rc::Rc::new(|state: &BattleState<CustomRules>| { state .entities() .teams() .count() == 42 }), ) .fire(); assert_eq!( result.err().map(|e| e.unfold()), Some(WeaselError::ConditionUnsatisfied) );
Implementations
impl<'a, R, T, P> Conditional<'a, R, T, P> where
R: BattleRules,
T: EventTrigger<'a, R, P>,
P: 'a + EventProcessor<R>,
Condition<R>: Clone,
[src]
R: BattleRules,
T: EventTrigger<'a, R, P>,
P: 'a + EventProcessor<R>,
Condition<R>: Clone,
pub fn new(trigger: T, condition: Condition<R>) -> Self
[src]
Creates a new Conditional
decorator for an EventTrigger
.
Trait Implementations
impl<'a, R, T, P> EventTrigger<'a, R, P> for Conditional<'a, R, T, P> where
R: BattleRules,
T: EventTrigger<'a, R, P>,
P: 'a + EventProcessor<R>,
Condition<R>: Clone,
[src]
R: BattleRules,
T: EventTrigger<'a, R, P>,
P: 'a + EventProcessor<R>,
Condition<R>: Clone,
Auto Trait Implementations
impl<'a, R, T, P> !RefUnwindSafe for Conditional<'a, R, T, P>
impl<'a, R, T, P> !Send for Conditional<'a, R, T, P>
impl<'a, R, T, P> !Sync for Conditional<'a, R, T, P>
impl<'a, R, T, P> Unpin for Conditional<'a, R, T, P> where
T: Unpin,
T: Unpin,
impl<'a, R, T, P> !UnwindSafe for Conditional<'a, R, T, P>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,