diff --git a/src/overflow.rs b/src/overflow.rs index 4230c89b57b..76253ebcdab 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -463,7 +463,7 @@ impl<'a> Context<'a> { if let Some(rewrite) = rewrite { // splitn(2, *).next().unwrap() is always safe. - let rewrite_first_line = Ok(rewrite.splitn(2, '\n').next().unwrap().to_owned()); + let rewrite_first_line = Ok(rewrite.split('\n').next().unwrap().to_owned()); last_list_item.item = rewrite_first_line; Some(rewrite) } else { diff --git a/src/utils.rs b/src/utils.rs index b676803379f..66282f09fa5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -213,13 +213,13 @@ pub(crate) fn is_attributes_extendable(attrs_str: &str) -> bool { /// The width of the first line in s. #[inline] pub(crate) fn first_line_width(s: &str) -> usize { - unicode_str_width(s.splitn(2, '\n').next().unwrap_or("")) + unicode_str_width(s.split('\n').next().unwrap_or("")) } /// The width of the last line in s. #[inline] pub(crate) fn last_line_width(s: &str) -> usize { - unicode_str_width(s.rsplitn(2, '\n').next().unwrap_or("")) + unicode_str_width(s.rsplit('\n').next().unwrap_or("")) } /// The total used width of the last line. diff --git a/src/visitor.rs b/src/visitor.rs index 4072a1d8697..0adaf049373 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -276,7 +276,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { let comment_snippet = self.snippet(span); let align_to_right = if unindent_comment && contains_comment(comment_snippet) { - let first_lines = comment_snippet.splitn(2, '/').next().unwrap_or(""); + let first_lines = comment_snippet.split('/').next().unwrap_or(""); last_line_width(first_lines) > last_line_width(comment_snippet) } else { false