cargo-crev 0.18.1

Scalable, social, Code REView system that we desperately need - Rust/cargo frontend
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::prelude::*;
use std::path::Path;
use tokei::{Config, LanguageType, Languages};

pub fn get_rust_line_count(path: &Path) -> Result<usize> {
    let excluded = &["tests/", "examples/"];
    let mut config = Config::default();
    config.treat_doc_strings_as_comments = Some(true);
    config.no_ignore_vcs = Some(true);
    config.hidden = Some(true);
    let mut languages = Languages::new();
    languages.get_statistics(&[path], excluded, &config);
    let rust = languages
        .get(&LanguageType::Rust)
        .ok_or_else(|| format_err!("Rust should work"))?;
    Ok(rust.code)
}