rstm_core/tail/
impl_tail_repr.rs

1/*
2    Appellation: impl_tail_repr <module>
3    Created At: 2025.09.04:19:35:05
4    Contrib: @FL03
5*/
6use super::{Tail, TailMut, TailRef};
7use rstm_state::RawState;
8
9impl<'a, Q, S> TailRef<'a, Q, S>
10where
11    Q: RawState,
12{
13    /// returns a new [`Tail`] with cloned elements
14    pub fn cloned(&self) -> Tail<Q, S>
15    where
16        Q: Clone,
17        S: Clone,
18    {
19        Tail {
20            direction: self.direction,
21            next_state: self.next_state.cloned(),
22            write_symbol: self.write_symbol.clone(),
23        }
24    }
25    /// returns a new [`Tail`] with copied elements
26    pub fn copied(&self) -> Tail<Q, S>
27    where
28        Q: Copy,
29        S: Copy,
30    {
31        Tail {
32            direction: self.direction,
33            next_state: self.next_state.copied(),
34            write_symbol: *self.write_symbol,
35        }
36    }
37}
38
39impl<'a, Q, S> TailMut<'a, Q, S>
40where
41    Q: RawState,
42{
43    /// returns a new [`Tail`] with cloned elements
44    pub fn cloned(&self) -> Tail<Q, S>
45    where
46        Q: Clone,
47        S: Clone,
48    {
49        Tail {
50            direction: self.direction,
51            next_state: self.next_state.cloned(),
52            write_symbol: self.write_symbol.clone(),
53        }
54    }
55    /// returns a new [`Tail`] with copied elements
56    pub fn copied(&self) -> Tail<Q, S>
57    where
58        Q: Copy,
59        S: Copy,
60    {
61        Tail {
62            direction: self.direction,
63            next_state: self.next_state.copied(),
64            write_symbol: *self.write_symbol,
65        }
66    }
67}