pub fn parse_set(input: &str) -> Result<ParsedSet, String>Expand description
Classify one :set argument (without the :set prefix).
Checked in this order, first match wins: contains = →
ParsedSet::Assign; ends in ? → ParsedSet::Query; ends in
& → ParsedSet::Reset; starts with no →
ParsedSet::Negate; otherwise ParsedSet::NameOnly. Err for
empty input or an empty name before = / ?.
The no test is purely lexical: any name beginning with no
parses as a negation of the remainder, so an option whose own name
starts with no cannot be reached by the bare name form.
§Examples
use lattice_config::{ParsedSet, parse_set};
assert_eq!(
parse_set("tabstop = 4"),
Ok(ParsedSet::Assign { name: "tabstop".into(), value: "4".into() })
);
assert_eq!(parse_set("number?"), Ok(ParsedSet::Query("number".into())));
assert_eq!(parse_set("nowrap"), Ok(ParsedSet::Negate("wrap".into())));
assert_eq!(parse_set("&"), Ok(ParsedSet::Reset(String::new())));
assert!(parse_set("=4").is_err());