MCPcopy Index your code
hub / github.com/cloud-hypervisor/cloud-hypervisor / parse_inner

Method parse_inner

option_parser/src/lib.rs:131–158  ·  view source on GitHub ↗
(&mut self, input: &str, ignore_unknown: bool)

Source from the content-addressed store, hash-verified

129 }
130
131 fn parse_inner(&mut self, input: &str, ignore_unknown: bool) -> OptionParserResult<()> {
132 if input.trim().is_empty() {
133 return Ok(());
134 }
135
136 for option in split_commas(input)?.iter() {
137 let parts: Vec<&str> = option.splitn(2, '=').collect();
138 match self.options.get_mut(parts[0]) {
139 None => {
140 if !ignore_unknown {
141 return Err(OptionParserError::UnknownOption(parts[0].to_owned()));
142 }
143 }
144 Some(value) => {
145 if value.requires_value {
146 if parts.len() != 2 {
147 return Err(OptionParserError::InvalidSyntax((*option).to_owned()));
148 }
149 value.value = Some(parts[1].trim().to_owned());
150 } else {
151 value.value = Some(String::new());
152 }
153 }
154 }
155 }
156
157 Ok(())
158 }
159
160 /// Parses a comma-separated `key=value` string, updating registered options.
161 ///

Callers 2

parseMethod · 0.80
parse_subsetMethod · 0.80

Calls 6

split_commasFunction · 0.85
newFunction · 0.85
iterMethod · 0.80
is_emptyMethod · 0.45
get_mutMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected