Skip to content

Commit

Permalink
Reformat trim_newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeah committed Nov 26, 2015
1 parent f5fac4c commit 314aff1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/utils.rs
Expand Up @@ -144,12 +144,12 @@ pub fn semicolon_for_stmt(stmt: &ast::Stmt) -> bool {

#[inline]
pub fn trim_newlines(input: &str) -> &str {
let start = input.find(|c| c != '\n' && c != '\r').unwrap_or(0);
let end = input.rfind(|c| c != '\n' && c != '\r').unwrap_or(0) + 1;
if start == 0 && end == 1 {
input
} else {
&input[start..end]
match input.find(|c| c != '\n' && c != '\r') {
Some(start) => {
let end = input.rfind(|c| c != '\n' && c != '\r').unwrap_or(0) + 1;
&input[start..end]
}
None => "",
}
}

Expand Down

0 comments on commit 314aff1

Please sign in to comment.