use string::{StringFormat, rewrite_string};
use utils::wrap_str;
+fn is_custom_comment(comment: &str) -> bool {
+ if !comment.starts_with("//") {
+ false
+ } else {
+ if let Some(c) = comment.chars().nth(2) {
+ !c.is_alphanumeric() && !c.is_whitespace()
+ } else {
+ false
+ }
+ }
+}
+
pub fn rewrite_comment(orig: &str,
block_style: bool,
width: usize,
("/// ", "", "/// ")
} else if orig.starts_with("//!") || orig.starts_with("/*!") {
("//! ", "", "//! ")
+ } else if is_custom_comment(orig) {
+ if orig.chars().nth(3) == Some(' ') {
+ (&orig[0..4], "", &orig[0..4])
+ } else {
+ (&orig[0..3], "", &orig[0..3])
+ }
} else {
("// ", "", "// ")
};
if line.starts_with("//! ") || line.starts_with("/// ") || line.starts_with("/*! ") ||
line.starts_with("/** ") {
&line[4..]
+ } else if is_custom_comment(line) {
+ if line.len() > 3 && line.chars().nth(3) == Some(' ') {
+ &line[4..]
+ } else {
+ &line[3..]
+ }
} else if line.starts_with("/* ") || line.starts_with("// ") || line.starts_with("//!") ||
line.starts_with("///") ||
line.starts_with("** ") || line.starts_with("/*!") ||
--- /dev/null
+// rustfmt-wrap_comments: true
+
+//@ special comment
+//@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec adiam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
+//@
+//@foo
+fn test() {}
\ No newline at end of file
--- /dev/null
+// rustfmt-wrap_comments: true
+
+//@ special comment
+//@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec adiam
+//@ lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
+//@
+//@ foo
+fn test() {}