use std::collections::BTreeSet;
#[must_use]
pub fn remove(text: &str, lines: &BTreeSet<usize>) -> String {
text.split_inclusive('\n')
.enumerate()
.filter(|(index, _)| !lines.contains(&(index + 1)))
.map(|(_, line)| line)
.collect()
}
#[must_use]
pub fn removable(line: &str) -> bool {
let trimmed = line.trim();
let body = if let Some(comment) = trimmed.strip_prefix("//") {
let comment = comment.trim_start();
let Some(body) = comment.strip_prefix("#[").and_then(|rest| rest.strip_suffix(']')) else {
return false;
};
body
} else {
trimmed
.strip_prefix("#[")
.and_then(|rest| rest.strip_suffix(']'))
.unwrap_or(trimmed)
};
if !body.starts_with("gamma::skip") {
return false;
}
let opened = body.matches('(').count();
opened == body.matches(')').count() && !body.contains("//")
}