MCPcopy Create free account
hub / github.com/bootc-dev/bootc / add

Method add

crates/kernel_cmdline/src/bytes.rs:217–237  ·  view source on GitHub ↗

Add a parameter to the command line if it doesn't already exist Returns `Action::Added` if the parameter did not already exist and was added. Returns `Action::Existed` if the exact parameter (same key and value) already exists. No modification was made. Unlike `add_or_modify`, this method will not modify existing parameters. If a parameter with the same key exists but has a different value, the

(&mut self, param: &Parameter)

Source from the content-addressed store, hash-verified

215 /// different value, the new parameter is still added, allowing
216 /// duplicate keys (e.g., multiple `console=` parameters).
217 pub fn add(&mut self, param: &Parameter) -> Action {
218 // Check if the exact parameter already exists
219 for p in self.iter() {
220 if p == *param {
221 // Exact match found, don't add duplicate
222 return Action::Existed;
223 }
224 }
225
226 // The exact parameter was not found, so we append it.
227 let self_mut = self.0.to_mut();
228 if self_mut
229 .last()
230 .filter(|v| !v.is_ascii_whitespace())
231 .is_some()
232 {
233 self_mut.push(b' ');
234 }
235 self_mut.extend_from_slice(param.parameter);
236 Action::Added
237 }
238
239 /// Add or modify a parameter to the command line
240 ///

Callers 1

extendMethod · 0.45

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected