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 as code, comments, documentation, or blanks.

§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.

§Modifications from original

  • Adapted to use rustloclib’s LocStats and Locs types
  • Added from_reader constructor for testing without files
  • Changed from whitespaces to blanks field naming
  • Added proper error handling instead of panics

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§

parse_file
Parse a single Rust file and return LOC statistics.
parse_string
Parse Rust source from a string and return LOC statistics.