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

Function parse_value

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

Ensures that a combination of [`Keyword`] and [`Value`] uses a [`Value::Single`] and parses the value as a specific type. # Errors Returns a error for `keyword` if `value` is not [`Value::Single`] or cannot be parsed as the specific type.

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

Source from the content-addressed store, hash-verified

135///
136/// Returns a error for `keyword` if `value` is not [`Value::Single`] or cannot be parsed as the
137/// specific type.
138fn parse_value<'a, O, P: Parser<&'a str, O, ErrMode<ContextError>>>(
139 keyword: &Keyword,
140 value: &'a Value,
141 mut parser: P,
142) -> Result<O, BridgeError> {
143 let input = ensure_single_value(keyword, value)?;
144 Ok(parser.parse(input).map_err(|err| (keyword.clone(), err))?)
145}
146
147/// Ensures a combination of [`Keyword`] and [`Value`] uses a [`Value::Single`] and parses the value

Callers 2

try_fromMethod · 0.85
handle_package_baseFunction · 0.85

Calls 2

ensure_single_valueFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected