use crate::fst_traits::MutableFst;
#[derive(Debug, Clone, PartialEq, PartialOrd, Copy)]
pub enum ProjectType {
ProjectInput,
ProjectOutput,
}
pub fn project<F: MutableFst>(fst: &mut F, project_type: ProjectType) {
match project_type {
ProjectType::ProjectInput => {
for state in 0..fst.num_states() {
for arc in unsafe { fst.arcs_iter_unchecked_mut(state) } {
arc.olabel = arc.ilabel;
}
}
}
ProjectType::ProjectOutput => {
for state in 0..fst.num_states() {
for arc in unsafe { fst.arcs_iter_unchecked_mut(state) } {
arc.ilabel = arc.olabel;
}
}
}
};
}
#[cfg(test)]
mod tests {
use proptest::prelude::*;
use crate::fst_properties::FstProperties;
use crate::fst_traits::ExpandedFst;
use crate::proptest_fst::proptest_fst;
use super::*;
proptest! {
#[test]
fn test_project_input_proptest(mut fst in proptest_fst()) {
project(&mut fst, ProjectType::ProjectInput);
prop_assume!(fst.properties().unwrap().intersects(FstProperties::ACCEPTOR));
}
}
proptest! {
#[test]
fn test_project_output_proptest(mut fst in proptest_fst()) {
project(&mut fst, ProjectType::ProjectOutput);
prop_assume!(fst.properties().unwrap().intersects(FstProperties::ACCEPTOR));
}
}
}