blob: e1d7263f7682fd459d11f02a0515bf9e4a575c9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
use crate::{Assignment, AssignmentRef, NameRef, StateRef};
impl<'a> AssignmentRef<'a> {
pub(crate) fn new(name: NameRef<'a>, state: StateRef<'a>) -> AssignmentRef<'a> {
AssignmentRef { name, state }
}
/// Turn this reference into its owned counterpart.
pub fn to_owned(self) -> Assignment {
self.into()
}
}
impl<'a> From<AssignmentRef<'a>> for Assignment {
fn from(a: AssignmentRef<'a>) -> Self {
Assignment {
name: a.name.to_owned(),
state: a.state.to_owned(),
}
}
}
impl<'a> Assignment {
/// Provide a ref type to this owned instance.
pub fn as_ref(&'a self) -> AssignmentRef<'a> {
AssignmentRef::new(self.name.as_ref(), self.state.as_ref())
}
}
|