/// The type of a comment. #[derive(Debug, PartialEq, Eq)] enum Kind { /// A `///` comment, or something of the like. /// All lines in a comment should start with the same symbol.
SingleLines, /// A `/**` comment, where each other line can start with `*` and the /// entire block ends with `*/`.
MultiLine,
}
/// Preprocesses a C/C++ comment so that it is a valid Rust comment. pub(crate) fn preprocess(comment: &str) -> String { matchself::kind(comment) {
Some(Kind::SingleLines) => preprocess_single_lines(comment),
Some(Kind::MultiLine) => preprocess_multi_line(comment),
None => comment.to_owned(),
}
}
/// Gets the kind of the doc comment, if it is one. fn kind(comment: &str) -> Option<Kind> { if comment.starts_with("/*") {
Some(Kind::MultiLine)
} elseif comment.starts_with("//") {
Some(Kind::SingleLines)
} else {
None
}
}
/// Preprocesses multiple single line comments. /// /// Handles lines starting with both `//` and `///`. fn preprocess_single_lines(comment: &str) -> String {
debug_assert!(comment.starts_with("//"), "comment is not single line");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.