typed_sf/cmds/
left.rs

1use core::marker::PhantomData;
2
3use crate::bit::Bit;
4use crate::cmds::eof::EOF;
5use crate::core::{Command, Run, Runner, State};
6use crate::list::{Cons, List, Nil};
7
8/// Go left (`< <Next>` in SF) command.
9/// If left [`List`] is [`Nil`], current bit will be from
10/// `Default` attribute from state.
11#[derive(Debug)]
12pub struct Left<Next = EOF>(PhantomData<Next>)
13where
14    Next: Command;
15
16impl<Next> Command for Left<Next> where Next: Command {}
17
18impl<LeftNew, ValueNew, ValuePrev, RightPrev, Default, Next>
19    Runner<Cons<ValueNew, LeftNew>, ValuePrev, RightPrev, Default> for Left<Next>
20where
21    LeftNew: List,
22    ValueNew: Bit,
23    ValuePrev: Bit,
24    RightPrev: List,
25    Next: Runner<LeftNew, ValueNew, Cons<ValuePrev, RightPrev>, Default>,
26    Default: Bit,
27{
28    type Run = Run<Next, State<LeftNew, ValueNew, Cons<ValuePrev, RightPrev>, Default>>;
29}
30
31impl<Value, Right, Next, Default> Runner<Nil, Value, Right, Default> for Left<Next>
32where
33    Value: Bit,
34    Right: List,
35    Default: Bit,
36    Next: Runner<Nil, Default, Cons<Value, Right>, Default>,
37{
38    type Run = Run<Next, State<Nil, Default, Cons<Value, Right>, Default>>;
39}