MAINT: cargo fmt.

This commit is contained in:
Jeremy Wall 2018-09-03 00:06:15 -05:00
parent d24df3b852
commit 170e74209d
4 changed files with 27 additions and 40 deletions

View File

@ -1,8 +1,8 @@
//! Contains implementations of `InputIter`.
use std::iter::Iterator;
use std::fmt::Debug;
use std::iter::Iterator;
use super::{Offsetable, InputIter};
use super::{InputIter, Offsetable};
/// Implements `InputIter` for any slice of T.
#[derive(Debug)]
@ -29,7 +29,7 @@ impl<'a, T: Debug + 'a> Iterator for SliceIter<'a, T> {
Some(item) => {
self.offset += 1;
Some(item)
},
}
None => None,
}
}

View File

@ -1,6 +1,6 @@
//! A parser combinator library with a focus on fully abortable parsing and error handling.
use std::iter::Iterator;
use std::fmt::Display;
use std::iter::Iterator;
pub trait Offsetable {
fn get_offset(&self) -> usize;
@ -25,7 +25,7 @@ pub struct Error<E: Display> {
impl<E: Display> Error<E> {
// Constructs a new Error with an offset and no cause.
pub fn new<S: Offsetable>(err: E, offset: &S) -> Self {
Error{
Error {
err: err,
offset: offset.get_offset(),
cause: None,
@ -34,7 +34,7 @@ impl<E: Display> Error<E> {
// Constructs a new Error with an offset and a cause.
pub fn caused_by<S: Offsetable>(err: E, offset: &S, cause: Self) -> Self {
Error{
Error {
err: err,
offset: offset.get_offset(),
cause: Some(Box::new(cause)),
@ -62,9 +62,7 @@ impl<E: Display> Display for Error<E> {
try!(write!(f, "{}", self.err));
match self.cause {
Some(ref c) => write!(f, "\n\tCaused By:{}", c),
None => {
Ok(())
},
None => Ok(()),
}
}
}

View File

@ -1,5 +1,5 @@
use super::iter::SliceIter;
use super::{Result, Offsetable};
use super::{Offsetable, Result};
#[test]
fn test_slice_iter() {
@ -172,10 +172,7 @@ fn test_do_each() {
fn test_either_idents() {
let input_str = "foo";
let iter = SliceIter::new(input_str.as_bytes());
let result = either!(iter,
will_fail,
will_fail,
parse_three);
let result = either!(iter, will_fail, will_fail, parse_three);
assert!(result.is_complete());
if let Result::Complete(_, o) = result {
assert_eq!("foo".to_string(), o);
@ -188,10 +185,7 @@ fn test_either_idents() {
fn test_either_macros() {
let input_str = "foo";
let iter = SliceIter::new(input_str.as_bytes());
let result = either!(iter,
run!(will_fail),
run!(will_fail),
run!(parse_three));
let result = either!(iter, run!(will_fail), run!(will_fail), run!(parse_three));
assert!(result.is_complete());
if let Result::Complete(_, o) = result {
assert_eq!("foo".to_string(), o);
@ -204,9 +198,7 @@ fn test_either_macros() {
fn test_either_fail() {
let input_str = "foo";
let iter = SliceIter::new(input_str.as_bytes());
let result = either!(iter,
run!(will_fail),
run!(will_fail));
let result = either!(iter, run!(will_fail), run!(will_fail));
assert!(result.is_fail());
}
@ -214,10 +206,7 @@ fn test_either_fail() {
fn test_either_abort() {
let input_str = "foo";
let iter = SliceIter::new(input_str.as_bytes());
let result = either!(iter,
must!(will_fail),
parse_three,
run!(will_fail));
let result = either!(iter, must!(will_fail), parse_three, run!(will_fail));
assert!(result.is_abort());
}