pub fn gather_stats(source: &str, context: VisitorContext) -> LocsExpand description
Gather LOC statistics from a string of Rust source code.
The context determines how logic lines are categorized:
VisitorContext::Codeโ logic lines count ascodeVisitorContext::Testsโ logic lines count astestsVisitorContext::Exampleโ logic lines count asexamples
Comments, docs, and blanks are always counted regardless of context.
ยงExample
use rustloclib::{gather_stats, VisitorContext};
let source = r#"
fn main() {
println!("Hello");
}
"#;
let stats = gather_stats(source, VisitorContext::Code);
assert_eq!(stats.code, 3);