mirror of
https://github.com/themasch/nginx-log-parser.git
synced 2025-06-15 08:46:33 +00:00
chore(fmt): cargo fmt
This commit is contained in:
@ -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(|| {
|
||||||
|
@ -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]
|
||||||
|
Reference in New Issue
Block a user