From @KSXGitHub
Comments are pieces of code that is usually ignored and can be placed anywhere. Doc comments in most languages are usually ignored by the compiler/interpreter. But Rust's so-called "doc comments" are different from normal comments:
- Under every outer doc (
/// ..., /** ... */, or #[doc = "..."]) must be a language item. Otherwise, it is a syntax error.
- Every inner doc (
//! ..., /*! ... */, or #![doc = "..."]) must be placed within a language item. Otherwise, it is a syntax error.
- Doc comment is just syntactic sugar for the
#[doc] attribute.
Suggestion
Doc comment in Rust is a flavor of Markdown, therefore it should be highlighted as a Markdown code snippet.