reduce feature

This commit is contained in:
Eason
2024-06-12 17:55:10 +08:00
parent 1a301178f8
commit 9e641b5f09
4 changed files with 44 additions and 43 deletions

View File

@ -11,20 +11,20 @@ pub enum Action {
None = 7,
}
impl TryFrom<i32> for Action {
type Error = &'static str;
// impl TryFrom<i32> for Action {
// type Error = &'static str;
fn try_from(value: i32) -> Result<Self, Self::Error> {
match value {
0 => Ok(Action::Forward),
1 => Ok(Action::Backward),
2 => Ok(Action::TurnRight),
3 => Ok(Action::TurnLeft),
4 => Ok(Action::AimRight),
5 => Ok(Action::AimLeft),
6 => Ok(Action::Shoot),
7 => Ok(Action::None),
_ => Err("Invalid action"),
}
}
}
// fn try_from(value: i32) -> Result<Self, Self::Error> {
// match value {
// 0 => Ok(Action::Forward),
// 1 => Ok(Action::Backward),
// 2 => Ok(Action::TurnRight),
// 3 => Ok(Action::TurnLeft),
// 4 => Ok(Action::AimRight),
// 5 => Ok(Action::AimLeft),
// 6 => Ok(Action::Shoot),
// 7 => Ok(Action::None),
// _ => Err("Invalid action"),
// }
// }
// }