/// Parses a kernel version string, in major.minor.release syntax.
///
/// Note that any extra information (stuff after a dash) is ignored.
///
/// # Example
///
/// ```
/// # use procfs::KernelVersion;
/// let a = KernelVersion::from_str("3.16.0-6-amd64").unwrap();
/// let b = KernelVersion::new(3, 16, 0);
/// assert_eq!(a, b);
///
/// ```
Parses a kernel version string, in major.minor.release syntax.
Note that any extra information (stuff after a dash) is ignored.
Parses a kernel version string in major . minor . release syntax . Note that any extra information ( stuff after a dash ) is ignored .
pub fn from_str(s: &str) -> Result<KernelVersion, &'static str> {
        let mut s = s.split('-');
        let kernel = s.next().unwrap();
        let mut kernel_split = kernel.split('.');
        let major = kernel_split
            .next()
            .ok_or("Missing major version component")?;
        let minor = kernel_split
            .next()
            .ok_or("Missing minor version component")?;
        let patch = kernel_split
            .next()
            .ok_or("Missing patch version component")?;
        let major = major.parse().map_err(|_| "Failed to parse major version")?;
        let minor = minor.parse().map_err(|_| "Failed to parse minor version")?;
        let patch = patch.parse().map_err(|_| "Failed to parse patch version")?;
        Ok(KernelVersion {
            major,
            minor,
            patch,
        })
    }
pub fn from_str ( s : & str ) -> Result < KernelVersion , & ' static str > { let mut s = s . split ( '-' ) ; let kernel = s . next ( ) . unwrap ( ) ; let mut kernel_split = kernel . split ( '.' ) ; let major = kernel_split . next ( ) . ok_or ( " " ) ? ; let minor = kernel_split . next ( ) . ok_or ( " " ) ? ; let patch = kernel_split . next ( ) . ok_or ( " " ) ? ; let major = major . parse ( ) . map_err ( | _ | " " ) ? ; let minor = minor . parse ( ) . map_err ( | _ | " " ) ? ; let patch = patch . parse ( ) . map_err ( | _ | " " ) ? ; Ok ( KernelVersion { major , minor , patch , } ) }
Parses a kernel version string, in major.minor.release syntax.
Parses a kernel version string in major . minor . release syntax .
s
&str
example
None
use procfs::kernelversion;
None