MCPcopy Create free account
hub / github.com/archlinux/alpm / parse_value_array

Function parse_value_array

alpm-srcinfo/src/pkgbuild_bridge/mod.rs:181–191  ·  view source on GitHub ↗

Parses a [`Value`] as a [`Vec`] of specific types. Does not differentiate between [`Value::Single`] and [`Value::Array`] variants, as a [`PKGBUILD`] allows either for array values. # Errors Returns a error for `keyword` if `value` cannot be parsed. [`PKGBUILD`]: https://man.archlinux.org/man/PKGBUILD.5

(
    keyword: &Keyword,
    value: &'a Value,
    mut parser: P,
)

Source from the content-addressed store, hash-verified

179/// Returns a error for `keyword` if `value` cannot be parsed.
180///
181/// [`PKGBUILD`]: https://man.archlinux.org/man/PKGBUILD.5
182fn parse_value_array<'a, O, P: Parser<&'a str, O, ErrMode<ContextError>>>(
183 keyword: &Keyword,
184 value: &'a Value,
185 mut parser: P,
186) -> Result<Vec<O>, BridgeError> {
187 let input = value.as_vec();
188 Ok(input
189 .into_iter()
190 .map(|item| parser.parse(item).map_err(|err| (keyword.clone(), err)))
191 .collect::<Result<Vec<O>, (Keyword, ParseError<&'a str, ContextError>)>>()?)
192}
193
194/// Parses a [`Value`] as [`Architectures`].

Callers 2

try_fromMethod · 0.85
handle_package_baseFunction · 0.85

Calls 3

as_vecMethod · 0.80
parseMethod · 0.80
into_iterMethod · 0.45

Tested by

no test coverage detected