pub fn insert<T: AsRef<str>>(&mut self, key: T, val: T) -> Result<()> {
        let k = key.as_ref();
        let v = val.as_ref();

        valid_element(k)?;
        valid_element(v)?;
        self.has_capacity(k.len() + v.len() + 1)?;

        self.start_push();
        self.line.push_str(k);
        self.line.push('=');
        self.line.push_str(v);
        self.end_push();

        Ok(())
    }
/// Validates and inserts a key-value pair into this command line.
///
/// # Arguments
///
/// * `key` - Key to be inserted in the command line string.
/// * `val` - Value corresponding to `key`.
///
/// # Examples
///
/// ```rust
/// # use linux_loader::cmdline::*;
/// # use std::ffi::CString;
/// let mut cl = Cmdline::new(100);
/// cl.insert("foo", "bar");
/// let cl_cstring = CString::new(cl).unwrap();
/// assert_eq!(cl_cstring.to_str().unwrap(), "foo=bar");
/// ```
Validates and inserts a key-value pair into this command line.
Validates and inserts a key - value pair into this command line .
pub fn insert<T: AsRef<str>>(&mut self, key: T, val: T) -> Result<()> {
        let k = key.as_ref();
        let v = val.as_ref();
        valid_element(k)?;
        valid_element(v)?;
        self.has_capacity(k.len() + v.len() + 1)?;
        self.start_push();
        self.line.push_str(k);
        self.line.push('=');
        self.line.push_str(v);
        self.end_push();
        Ok(())
    }
pub fn insert < T : AsRef < str > > ( & mut self , key : T , val : T ) -> Result < ( ) > { let k = key . as_ref ( ) ; let v = val . as_ref ( ) ; valid_element ( k ) ? ; valid_element ( v ) ? ; self . has_capacity ( k . len ( ) + v . len ( ) + 1 ) ? ; self . start_push ( ) ; self . line . push_str ( k ) ; self . line . push ( '=' ) ; self . line . push_str ( v ) ; self . end_push ( ) ; Ok ( ( ) ) }
Validates and inserts a key-value pair into this command line.
Validates and inserts a key - value pair into this command line .
&mut self
key
T
val
T
&mut self
key
T
val
T
examples
None
use linux_loader::cmdline::*;
None
use std::ffi::cstring;
let mut cl = Cmdline::new(100);
cl.insert("foo", "bar");
let cl_cstring = CString::new(cl).unwrap();
assert_eq!(cl_cstring.to_str().unwrap(), "foo=bar");
```
let mut cl = Cmdline :: new ( 100 ) ; cl . insert ( " foo " " bar " ) ; let cl_cstring = CString :: new ( cl ) . unwrap () ; assert_eq! ( cl_cstring . to_str () . unwrap () " foo = bar " ) ; ` ` `