use Result::or for Either::from_str

This commit is contained in:
Isse 2023-11-26 15:37:14 +01:00
parent a151a6f550
commit a4caa2bc26

View File

@ -4573,13 +4573,9 @@ fn handle_tether(
type Err = B::Err; type Err = B::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
match A::from_str(s) { A::from_str(s)
Ok(a) => Ok(Either::Left(a)), .map(Either::Left)
Err(_) => match B::from_str(s) { .or_else(|_| B::from_str(s).map(Either::Right))
Ok(b) => Ok(Either::Right(b)),
Err(e) => Err(e),
},
}
} }
} }
if let (Some(entity_target), length) = parse_cmd_args!(args, EntityTarget, Either<f32, bool>) { if let (Some(entity_target), length) = parse_cmd_args!(args, EntityTarget, Either<f32, bool>) {