pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let is_swift_project = context
        .try_begin_scan()?
        .set_extensions(&["swift"])
        .is_match();

    if !is_swift_project {
        return None;
    }

    let swift_version = utils::exec_cmd("swift", &["--version"])?.stdout;

    let mut module = context.new_module("swift");
    let config: SwiftConfig = SwiftConfig::try_load(module.config);

    let parsed = StringFormatter::new(config.format).and_then(|formatter| {
        formatter
            .map_meta(|var, _| match var {
                "symbol" => Some(config.symbol),
                _ => None,
            })
            .map_style(|variable| match variable {
                "style" => Some(Ok(config.style)),
                _ => None,
            })
            .map(|variable| match variable {
                "version" => parse_swift_version(&swift_version).map(Ok),
                _ => None,
            })
            .parse(None)
    });

    module.set_segments(match parsed {
        Ok(segments) => segments,
        Err(error) => {
            log::warn!("Error in module `swift`:\n{}", error);
            return None;
        }
    });

    Some(module)
}
/// Creates a module with the current Swift version
///
/// Will display the Swift version if any of the following criteria are met:
///     - The current directory contains a `Package.swift` file
///     - The current directory contains a file with extension `.swift`
Creates a module with the current Swift version
Will display the Swift version if any of the following criteria are met:
The current directory contains a `Package.swift` file
The current directory contains a file with extension `.swift`
Creates a module with the current Swift version Will display the Swift version if any of the following criteria are met : The current directory contains a ` Package . swift ` file The current directory contains a file with extension ` . swift `
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let is_swift_project = context
        .try_begin_scan()?
        .set_extensions(&["swift"])
        .is_match();
    if !is_swift_project {
        return None;
    }
    let swift_version = utils::exec_cmd("swift", &["--version"])?.stdout;
    let mut module = context.new_module("swift");
    let config: SwiftConfig = SwiftConfig::try_load(module.config);
    let parsed = StringFormatter::new(config.format).and_then(|formatter| {
        formatter
            .map_meta(|var, _| match var {
                "symbol" => Some(config.symbol),
                _ => None,
            })
            .map_style(|variable| match variable {
                "style" => Some(Ok(config.style)),
                _ => None,
            })
            .map(|variable| match variable {
                "version" => parse_swift_version(&swift_version).map(Ok),
                _ => None,
            })
            .parse(None)
    });
    module.set_segments(match parsed {
        Ok(segments) => segments,
        Err(error) => {
            log::warn!("Error in module `swift`:\n{}", error);
            return None;
        }
    });
    Some(module)
}
pub fn module < ' a > ( context : & ' a Context ) -> Option < Module < ' a > > { let is_swift_project = context . try_begin_scan ( ) ? . set_extensions ( & [ " " ] ) . is_match ( ) ; if ! is_swift_project { return None ; } let swift_version = utils :: exec_cmd ( " " , & [ " " ] ) ? . stdout ; let mut module = context . new_module ( " " ) ; let config : SwiftConfig = SwiftConfig :: try_load ( module . config ) ; let parsed = StringFormatter :: new ( config . format ) . and_then ( | formatter | { formatter . map_meta ( | var , _ | match var { " " => Some ( config . symbol ) , _ => None , } ) . map_style ( | variable | match variable { " " => Some ( Ok ( config . style ) ) , _ => None , } ) . map ( | variable | match variable { " " => parse_swift_version ( & swift_version ) . map ( Ok ) , _ => None , } ) . parse ( None ) } ) ; module . set_segments ( match parsed { Ok ( segments ) => segments , Err ( error ) => { log :: warn ! ( " \n " error ) ; return None ; } } ) ; Some ( module ) }
Creates a module with the current Swift version
Will display the Swift version if any of the following criteria are met:
 The current directory contains a `Package.swift` file
 The current directory contains a file with extension `.swift`
Creates a module with the current Swift version Will display the Swift version if any of the following criteria are met : The current directory contains a ` Package . swift ` file The current directory contains a file with extension ` . swift `
context
&'a Context