MCPcopy Create free account
hub / github.com/FastLED/FastLED / strip_line_comment_code

Function strip_line_comment_code

ci/lint_cpp_rs/src/lib.rs:3323–3342  ·  view source on GitHub ↗
(line: &str)

Source from the content-addressed store, hash-verified

3321}
3322
3323fn strip_line_comment_code(line: &str) -> String {
3324 let mut in_string = false;
3325 let mut in_char = false;
3326 let mut previous = '\0';
3327 let chars: Vec<(usize, char)> = line.char_indices().collect();
3328 for (idx, ch) in &chars {
3329 if *ch == '"' && !in_char && previous != '\\' {
3330 in_string = !in_string;
3331 } else if *ch == '\'' && !in_string && previous != '\\' {
3332 in_char = !in_char;
3333 } else if !in_string && !in_char && *ch == '/' {
3334 let next_is_slash = line[*idx + ch.len_utf8()..].starts_with('/');
3335 if next_is_slash {
3336 return line[..*idx].to_string();
3337 }
3338 }
3339 previous = *ch;
3340 }
3341 line.to_string()
3342}
3343
3344fn classify_noexcept_line(
3345 line: &str,

Callers 2

classify_noexcept_lineFunction · 0.85
join_multiline_signatureFunction · 0.85

Calls 2

starts_withMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected