Skip to main content

strip_comments

Function strip_comments 

Source
pub fn strip_comments(code: &str) -> String
Expand description

Strip single-line (//) and block (/* */) comments from Rust source.

This is a best-effort heuristic for phase 1 validation. It does not handle string literals containing comment-like sequences, but that is acceptable for the patterns we check (e.g., fn main inside a string literal is unlikely and would be caught at compile time anyway).