rstm_core/rules/traits/
convert.rs1use crate::{Direction, Head, Tail};
7
8pub trait AsHead<Q, A> {
10 fn as_head(&self) -> Head<Q, A>;
11}
12pub trait IntoHead<Q, A> {
14 fn into_head(self) -> Head<Q, A>;
15}
16
17pub trait AsTail<Q, A> {
19 fn as_tail(&self) -> Tail<Q, A>;
20}
21pub trait IntoTail<Q, A> {
23 fn into_tail(self) -> Tail<Q, A>;
24}
25pub trait IntoDirection {
27 fn into_direction(self) -> Direction;
28}
29impl<T> IntoDirection for T
33where
34 T: Into<Direction>,
35{
36 fn into_direction(self) -> Direction {
37 self.into()
38 }
39}
40
41impl<Q, A, T> IntoHead<Q, A> for T
42where
43 T: Into<Head<Q, A>>,
44{
45 fn into_head(self) -> Head<Q, A> {
46 self.into()
47 }
48}
49
50impl<Q, A, T> IntoTail<Q, A> for T
51where
52 T: Into<Tail<Q, A>>,
53{
54 fn into_tail(self) -> Tail<Q, A> {
55 self.into()
56 }
57}