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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::Label;
#[derive(PartialOrd, PartialEq, Copy, Clone, Debug, Eq)]
pub enum ReplaceLabelType {
Neither,
Input,
Output,
#[allow(unused)]
Both,
}
#[derive(PartialOrd, PartialEq, Clone, Debug, Eq)]
pub struct ReplaceFstOptions {
pub root: Label,
pub call_label_type: ReplaceLabelType,
pub return_label_type: ReplaceLabelType,
pub call_output_label: Option<Label>,
pub return_label: Label,
}
impl ReplaceFstOptions {
pub fn new(root: Label, epsilon_on_replace: bool) -> Self {
Self {
root,
call_label_type: if epsilon_on_replace {
ReplaceLabelType::Neither
} else {
ReplaceLabelType::Input
},
return_label_type: ReplaceLabelType::Neither,
call_output_label: if epsilon_on_replace { Some(0) } else { None },
return_label: 0,
}
}
}