use std::{self, borrow::Cow, iter};
use itertools::{multipeek, MultiPeek};
use std::{self, borrow::Cow, iter};
use itertools::{multipeek, MultiPeek};
| CommentStyle::TripleSlash
| CommentStyle::Custom(..)
| CommentStyle::Doc => "",
| CommentStyle::TripleSlash
| CommentStyle::Custom(..)
| CommentStyle::Doc => "",
CommentStyle::DoubleSlash => "// ",
CommentStyle::TripleSlash => "/// ",
CommentStyle::Doc => "//! ",
CommentStyle::DoubleSlash => "// ",
CommentStyle::TripleSlash => "/// ",
CommentStyle::Doc => "//! ",
.checked_sub(closer.len() + opener.len())
.unwrap_or(1);
let indent_str = shape.indent.to_string_with_newline(config).to_string();
.checked_sub(closer.len() + opener.len())
.unwrap_or(1);
let indent_str = shape.indent.to_string_with_newline(config).to_string();
let mut cr = CommentRewrite {
result: String::with_capacity(orig.len() * 2),
let mut cr = CommentRewrite {
result: String::with_capacity(orig.len() * 2),
comment_line_separator: format!("{}{}", indent_str, line_start),
max_width,
indent_str,
comment_line_separator: format!("{}{}", indent_str, line_start),
max_width,
indent_str,
const RUSTFMT_CUSTOM_COMMENT_PREFIX: &str = "//#### ";
fn hide_sharp_behind_comment(s: &str) -> Cow<'_, str> {
const RUSTFMT_CUSTOM_COMMENT_PREFIX: &str = "//#### ";
fn hide_sharp_behind_comment(s: &str) -> Cow<'_, str> {
rewrite_comment(trimmed_snippet, false, shape, context.config)
} else {
Some(String::new())
rewrite_comment(trimmed_snippet, false, shape, context.config)
} else {
Some(String::new())
// We missed some comments. Warn and keep the original text.
if context.config.error_on_unformatted() {
context.report.append(
// We missed some comments. Warn and keep the original text.
if context.config.error_on_unformatted() {
context.report.append(