Skip to main content

Module util

Module util 

Source
Expand description

Small pure helpers: identifier casing, keyword handling, and comment scanning.

Functions§

extend_trailing_comment
If the remainder of the line after end is only a trailing // line comment, extend end to include it (but not the newline). Otherwise return end.
is_keyword
Is name a Rust keyword (used to decide whether a mod/use needs adjustment)?
leading_comment_start
Given the gap between the previous item’s end and this item’s start, return the byte offset at which a contiguous block of plain // comments directly above the item begins. Doc-comments are already part of the item span, so they never appear here. Returns item_start when there is no attached comment block.
line_start
Byte offset of the start of the line containing byte in src.
to_snake
Convert a Rust identifier (CamelCase, SCREAMING_SNAKE, or mixed) into a snake_case module file stem.