Fix empty trim_newline panic, add impl macro test

This commit is contained in:
Kevin Yeh 2015-11-24 14:37:31 -06:00
parent c408245e5d
commit f5fac4c54f
3 changed files with 21 additions and 1 deletions

View file

@ -146,7 +146,11 @@ pub fn semicolon_for_stmt(stmt: &ast::Stmt) -> bool {
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;
&input[start..end]
if start == 0 && end == 1 {
input
} else {
&input[start..end]
}
}
#[inline]

View file

@ -51,3 +51,10 @@ mod b {
}
}
}
impl Foo { add_fun!(); }
impl Blah {
fn boop() {}
add_fun!();
}

View file

@ -63,3 +63,12 @@ mod b {
}
}
}
impl Foo {
add_fun!();
}
impl Blah {
fn boop() {}
add_fun!();
}