Function racer::check_rust_src_env_var [] [src]

pub fn check_rust_src_env_var() -> Result<(), RustSrcPathError>

Check for RUST_SRC_PATH environment variable validity and presence

If the environment variable is not set, try and set it from the rust sys root.

If the rust src path is there and valid or can be set, Ok(()) is returned. Otherwise, an error with the appropriate reason is provided.

Examples

extern crate racer;

match racer::check_rust_src_env_var() {
    Ok(()) => {
        // RUST_SRC_PATH is valid
    },
    Err(racer::RustSrcPathError::Missing) => {
        // path is not set or not found in sysroot
    },
    Err(racer::RustSrcPathError::DoesNotExist(_path)) => {
        // provided path doesnt point to valid file
    },
    Err(racer::RustSrcPathError::NotRustSourceTree(_path)) => {
        // provided path doesn't have rustc src
    }
}