chore(fmt): cargo fmt

This commit is contained in:
Mark Schmale
2018-09-13 10:50:22 +02:00
parent 9bfac330f8
commit ddb69a1260
2 changed files with 11 additions and 7 deletions

View File

@ -8,9 +8,7 @@ use std::str::FromStr;
fn format_parser_bench(c: &mut Criterion) { fn format_parser_bench(c: &mut Criterion) {
c.bench_function("short format", |b| { c.bench_function("short format", |b| {
b.iter(|| { b.iter(|| Format::from_str(r#"$remote_addr [$time_local] "$request" $status"#))
Format::from_str(r#"$remote_addr [$time_local] "$request" $status"#)
})
}); });
c.bench_function("combined format", |b| { c.bench_function("combined format", |b| {
b.iter(|| { b.iter(|| {

View File

@ -181,9 +181,9 @@ fn read_format(bytes: &[u8]) -> Result<Format, FormatParserError> {
(Variable(start, end), Fixed(_, _)) => stack.push(FormatPart::Variable( (Variable(start, end), Fixed(_, _)) => stack.push(FormatPart::Variable(
create_owned_str(&bytes, *start, *end)?, create_owned_str(&bytes, *start, *end)?,
)), )),
(Variable(start, end), Variable(b_start, _)) if b_start > start => stack.push(FormatPart::Variable( (Variable(start, end), Variable(b_start, _)) if b_start > start => stack.push(
create_owned_str(&bytes, *start, *end)?, FormatPart::Variable(create_owned_str(&bytes, *start, *end)?),
)), ),
(Fixed(start, end), Variable(_, _)) => { (Fixed(start, end), Variable(_, _)) => {
stack.push(FormatPart::Fixed(create_owned_str(&bytes, *start, *end)?)) stack.push(FormatPart::Fixed(create_owned_str(&bytes, *start, *end)?))
} }
@ -266,7 +266,13 @@ mod test {
let format_input = "$remote_add$remote_user"; let format_input = "$remote_add$remote_user";
let format = Format::from_str(format_input).unwrap(); let format = Format::from_str(format_input).unwrap();
assert_eq!(vec![Variable(String::from("remote_add")), Variable(String::from("remote_user"))], format.parts); assert_eq!(
vec![
Variable(String::from("remote_add")),
Variable(String::from("remote_user")),
],
format.parts
);
} }
#[test] #[test]