roopes_core/patterns/command/
heap.rs1use crate::{
5 prelude::*,
6 primitives,
7};
8use delegate::delegate;
9
10pub struct Heap
13{
14 delegate: Box<dyn Command>,
15}
16
17impl Heap
18{
19 #[must_use]
22 pub fn new(delegate: Box<dyn Command>) -> Heap
23 {
24 Heap { delegate }
25 }
26}
27
28#[allow(clippy::inline_always)]
29impl Command for Heap
30{
31 delegate! {
32 to self.delegate {
33 fn execute(&self);
34 }
35 }
36}
37
38impl From<Heap> for Box<dyn Command>
39{
40 fn from(value: Heap) -> Self
41 {
42 value.delegate
43 }
44}
45
46impl From<Box<dyn Command>> for Heap
47{
48 fn from(delegate: Box<dyn Command>) -> Self
49 {
50 Heap { delegate }
51 }
52}
53
54impl<D> From<D> for Heap
55where
56 D: primitives::executable::lambda::Delegate + 'static,
57{
58 fn from(delegate: D) -> Self
59 {
60 let delegate =
61 Box::new(CommandExecutable::new(executable::Lambda::new(delegate)));
62
63 Heap { delegate }
64 }
65}