Parses a [`Value`] as [`Architectures`]. # Errors Returns an error for `keyword` if `value` cannot be parsed as either a stand-alone "any" or a list of [`SystemArchitecture`].
(keyword: &Keyword, value: &'a Value)
| 197 | /// |
| 198 | /// Returns an error for `keyword` if `value` cannot be parsed as either a stand-alone "any" or a |
| 199 | /// list of [`SystemArchitecture`]. |
| 200 | fn parse_arch_array<'a>(keyword: &Keyword, value: &'a Value) -> Result<Architectures, BridgeError> { |
| 201 | // `arch` may be a list or a single value (for backward compatibility). |
| 202 | let input = value.as_vec(); |
| 203 | |
| 204 | // First check if the entry is a single "any". |
| 205 | // `arch = "any"` |
| 206 | // or |
| 207 | // `arch = ("any")` |
| 208 | if input.len() == 1 && input[0] == "any" { |
| 209 | return Ok(Architectures::Any); |
| 210 | } |
| 211 | |
| 212 | let architectures = input |
| 213 | .into_iter() |
| 214 | .map(|item| { |
| 215 | SystemArchitecture::parser |
| 216 | .context(StrContext::Expected(StrContextValue::Description( |
| 217 | "either a single 'any' or an array of one or more specific system architectures." |
| 218 | ))) |
| 219 | .parse(item) |
| 220 | .map_err(|err| (keyword.clone(), err)) |
| 221 | }) |
| 222 | .collect::<Result<Vec<SystemArchitecture>, (Keyword, ParseError<&'a str, ContextError>)>>()?; |
| 223 | |
| 224 | Ok(Architectures::Some(architectures)) |
| 225 | } |
| 226 | |
| 227 | #[cfg(test)] |
no test coverage detected