Skip to content

Commit

Permalink
fix edition idioms
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelc authored and Geal committed Aug 9, 2021
1 parent f5de114 commit 5a65658
Show file tree
Hide file tree
Showing 18 changed files with 9 additions and 46 deletions.
2 changes: 0 additions & 2 deletions benches/arithmetic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extern crate nom;
#[macro_use]
extern crate criterion;
extern crate jemallocator;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
Expand Down
11 changes: 4 additions & 7 deletions benches/http.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![cfg_attr(rustfmt, rustfmt_skip)]

extern crate criterion;
extern crate jemallocator;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down Expand Up @@ -70,7 +67,7 @@ fn is_version(c: u8) -> bool {
c >= b'0' && c <= b'9' || c == b'.'
}

fn request_line(input: &[u8]) -> IResult<&[u8], Request> {
fn request_line(input: &[u8]) -> IResult<&[u8], Request<'_>> {
let (input, method) = take_while1(is_token)(input)?;
let (input, _) = take_while1(is_space)(input)?;
let (input, uri) = take_while1(is_not_space)(input)?;
Expand All @@ -96,15 +93,15 @@ fn message_header_value(input: &[u8]) -> IResult<&[u8], &[u8]> {
Ok((input, data))
}

fn message_header(input: &[u8]) -> IResult<&[u8], Header> {
fn message_header(input: &[u8]) -> IResult<&[u8], Header<'_>> {
let (input, name) = take_while1(is_token)(input)?;
let (input, _) = char(':')(input)?;
let (input, value) = many1(message_header_value)(input)?;

Ok((input, Header{ name, value }))
}

fn request(input: &[u8]) -> IResult<&[u8], (Request, Vec<Header>)> {
fn request(input: &[u8]) -> IResult<&[u8], (Request<'_>, Vec<Header<'_>>)> {
let (input, req) = request_line(input)?;
let (input, h) = many1(message_header)(input)?;
let (input, _) = line_ending(input)?;
Expand All @@ -113,7 +110,7 @@ fn request(input: &[u8]) -> IResult<&[u8], (Request, Vec<Header>)> {
}


fn parse(data: &[u8]) -> Option<Vec<(Request, Vec<Header>)>> {
fn parse(data: &[u8]) -> Option<Vec<(Request<'_>, Vec<Header<'_>>)>> {
let mut buf = &data[..];
let mut v = Vec::new();
loop {
Expand Down
3 changes: 0 additions & 3 deletions benches/ini.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
extern crate criterion;
extern crate jemallocator;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down
3 changes: 0 additions & 3 deletions benches/ini_str.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
extern crate criterion;
extern crate jemallocator;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down
2 changes: 0 additions & 2 deletions benches/json.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extern crate nom;
#[macro_use]
extern crate criterion;
extern crate jemallocator;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
Expand Down
2 changes: 0 additions & 2 deletions benches/number.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
extern crate nom;
#[macro_use]
extern crate criterion;
extern crate jemallocator;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
Expand Down
3 changes: 0 additions & 3 deletions examples/json.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![cfg(feature = "alloc")]

extern crate jemallocator;
extern crate nom;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down
3 changes: 0 additions & 3 deletions examples/s_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#![cfg(feature = "alloc")]

extern crate jemallocator;
extern crate nom;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down
3 changes: 0 additions & 3 deletions examples/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#![cfg(feature = "alloc")]

extern crate jemallocator;
extern crate nom;

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

Expand Down
2 changes: 1 addition & 1 deletion src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<E> fmt::Display for Err<E>
where
E: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Err::Incomplete(Needed::Size(u)) => write!(f, "Parsing requires {} bytes/chars", u),
Err::Incomplete(Needed::Unknown) => write!(f, "Parsing requires more data"),
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,7 @@
extern crate alloc;
#[cfg(doctest)]
extern crate doc_comment;
#[cfg(feature = "lexical")]
extern crate lexical_core;
extern crate memchr;

#[cfg(nightly)]
extern crate test;

Expand Down
2 changes: 0 additions & 2 deletions tests/arithmetic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate nom;

use nom::{
branch::alt,
bytes::complete::tag,
Expand Down
6 changes: 2 additions & 4 deletions tests/arithmetic_ast.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate nom;

use std::fmt;
use std::fmt::{Debug, Display, Formatter};

Expand Down Expand Up @@ -33,7 +31,7 @@ pub enum Oper {
}

impl Display for Expr {
fn fmt(&self, format: &mut Formatter) -> fmt::Result {
fn fmt(&self, format: &mut Formatter<'_>) -> fmt::Result {
use self::Expr::*;
match *self {
Value(val) => write!(format, "{}", val),
Expand All @@ -47,7 +45,7 @@ impl Display for Expr {
}

impl Debug for Expr {
fn fmt(&self, format: &mut Formatter) -> fmt::Result {
fn fmt(&self, format: &mut Formatter<'_>) -> fmt::Result {
use self::Expr::*;
match *self {
Value(val) => write!(format, "{}", val),
Expand Down
2 changes: 0 additions & 2 deletions tests/css.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate nom;

use nom::bytes::complete::{tag, take_while_m_n};
use nom::combinator::map_res;
use nom::sequence::tuple;
Expand Down
2 changes: 0 additions & 2 deletions tests/fnmut.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate nom;

use nom::{
bytes::complete::tag,
multi::{many0, many0_count},
Expand Down
1 change: 0 additions & 1 deletion tests/json.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg(feature = "alloc")]
extern crate nom;

use nom::{
branch::alt,
Expand Down
2 changes: 1 addition & 1 deletion tests/mp4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ fn brand_name(input: &[u8]) -> IResult<&[u8], &str> {
map_res(take(4_usize), str::from_utf8)(input)
}

fn filetype_parser(input: &[u8]) -> IResult<&[u8], FileType> {
fn filetype_parser(input: &[u8]) -> IResult<&[u8], FileType<'_>> {
let (i, name) = brand_name(input)?;
let (i, version) = take(4_usize)(i)?;
let (i, brands) = many0(brand_name)(i)?;
Expand Down
2 changes: 0 additions & 2 deletions tests/multiline.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate nom;

use nom::{
character::complete::{alphanumeric1 as alphanumeric, line_ending as eol},
multi::many0,
Expand Down

0 comments on commit 5a65658

Please sign in to comment.