diff options
| author | Philipp Hansch <dev@phansch.net> | 2018-12-18 03:21:31 +0100 |
|---|---|---|
| committer | Seiichi Uchida <seuchida@gmail.com> | 2018-12-18 11:21:31 +0900 |
| commit | d0785954c846dbfdc9116084a731ccd44b0205ce (patch) | |
| tree | b89f09563f845c4454138ad9804b642d3abef6c8 /src/string.rs | |
| parent | 16c292dcf8974d72bf1474a9653566e1e160d393 (diff) | |
Fix trim_right/trim_left deprecation warnings (#3252)
Diffstat (limited to 'src/string.rs')
| -rw-r--r-- | src/string.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/string.rs b/src/string.rs index 561d96813b0..668324b4d8f 100644 --- a/src/string.rs +++ b/src/string.rs @@ -107,7 +107,7 @@ pub fn rewrite_string<'a>( for (i, grapheme) in graphemes[cur_start..].iter().enumerate() { if is_line_feed(grapheme) { // take care of blank lines - result = trim_right_but_line_feed(fmt.trim_end, result); + result = trim_end_but_line_feed(fmt.trim_end, result); result.push_str("\n"); if !is_bareline_ok && cur_start + i + 1 < graphemes.len() { result.push_str(&indent_without_newline); @@ -117,7 +117,7 @@ pub fn rewrite_string<'a>( result.push_str(grapheme); } } - result = trim_right_but_line_feed(fmt.trim_end, result); + result = trim_end_but_line_feed(fmt.trim_end, result); break; } @@ -138,7 +138,7 @@ pub fn rewrite_string<'a>( } SnippetState::EndWithLineFeed(line, len) => { if line == "\n" && fmt.trim_end { - result = result.trim_right().to_string(); + result = result.trim_end().to_string(); } result.push_str(&line); if is_bareline_ok { @@ -188,11 +188,11 @@ fn detect_url(s: &[&str], index: usize) -> Option<usize> { } /// Trims whitespaces to the right except for the line feed character. -fn trim_right_but_line_feed(trim_end: bool, result: String) -> String { +fn trim_end_but_line_feed(trim_end: bool, result: String) -> String { let whitespace_except_line_feed = |c: char| c.is_whitespace() && c != '\n'; if trim_end && result.ends_with(whitespace_except_line_feed) { result - .trim_right_matches(whitespace_except_line_feed) + .trim_end_matches(whitespace_except_line_feed) .to_string() } else { result @@ -244,7 +244,7 @@ fn break_string(max_chars: usize, trim_end: bool, line_end: &str, input: &[&str] if i <= index_minus_ws { let mut line = &input[0..i].concat()[..]; if trim_end { - line = line.trim_right(); + line = line.trim_end(); } return SnippetState::EndWithLineFeed(format!("{}\n", line), i + 1); } |
