Skip to main content

Module visitor

Module visitor 

Source
Expand description

Rust source file visitor for LOC counting.

This module provides the core parsing logic for analyzing Rust source files and categorizing lines into one of 6 types:

  • code: Logic lines in production code
  • tests: Logic lines in test code (#test, #[cfg(test)], tests/)
  • examples: Logic lines in example code (examples/)
  • docs: Documentation comments (///, //!, /** /, /! */)
  • comments: Regular comments (//, /* */)
  • blanks: Blank/whitespace-only lines

§Acknowledgment

The parsing logic in this module is adapted from cargo-warloc by Maxim Gritsenko. Many thanks to the original author for the excellent implementation. cargo-warloc is licensed under MIT.

Structs§

Visitor
A visitor that parses Rust source files and counts lines of code.

Enums§

VisitorContext
The context in which code is being analyzed.

Functions§

gather_stats
Gather LOC statistics from a string of Rust source code.
gather_stats_for_path
Gather LOC statistics for a file at the given path.