Add rustfmt to travis (#137)

* RFC styling-based `rustfmt.toml`

* Add rustfmt to travis

* Remove rustfmt.toml and actually fix too-long lines instead of ignoring them
This commit is contained in:
Jef
2018-03-07 16:20:55 +01:00
committed by GitHub
parent e8d29af359
commit 5217e29fab
54 changed files with 5801 additions and 5572 deletions

View File

@ -23,20 +23,20 @@
//! Encoding and decoding state machines for protobuf varints
// TODO: Non-allocating `BigUint`?
extern crate bytes;
#[macro_use]
extern crate error_chain;
extern crate futures;
extern crate num_bigint;
extern crate num_traits;
extern crate tokio_io;
extern crate bytes;
extern crate futures;
#[macro_use]
extern crate error_chain;
use bytes::{BufMut, Bytes, BytesMut, IntoBuf};
use futures::{Poll, Async};
use futures::{Async, Poll};
use num_bigint::BigUint;
use num_traits::ToPrimitive;
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_io::codec::{Encoder, Decoder};
use tokio_io::codec::{Decoder, Encoder};
use std::io;
use std::io::prelude::*;
use std::marker::PhantomData;
@ -143,7 +143,10 @@ macro_rules! impl_decoderstate {
($t:ty, $make_fn:expr, $shift_fn:expr) => {
impl DecoderHelper for $t {
#[inline]
fn decode_one(decoder: &mut DecoderState<Self>, byte: u8) -> ::errors::Result<Option<$t>> {
fn decode_one(
decoder: &mut DecoderState<Self>,
byte: u8,
) -> ::errors::Result<Option<$t>> {
let res = decoder.accumulator.take().and_then(|accumulator| {
let out = accumulator | match $shift_fn(
$make_fn(byte & 0x7F),
@ -439,16 +442,14 @@ impl<T> Decoder for VarintCodec<T> {
self.inner = VarintCodecInner::WaitingForData(len);
return Ok(None);
}
},
VarintCodecInner::WaitingForLen(mut decoder) => {
match decoder.decode(src)? {
None => {
self.inner = VarintCodecInner::WaitingForLen(decoder);
return Ok(None);
},
Some(len) => {
self.inner = VarintCodecInner::WaitingForData(len);
},
}
VarintCodecInner::WaitingForLen(mut decoder) => match decoder.decode(src)? {
None => {
self.inner = VarintCodecInner::WaitingForLen(decoder);
return Ok(None);
}
Some(len) => {
self.inner = VarintCodecInner::WaitingForData(len);
}
},
VarintCodecInner::Poisoned => panic!("varint codec was poisoned"),
@ -458,7 +459,8 @@ impl<T> Decoder for VarintCodec<T> {
}
impl<D> Encoder for VarintCodec<D>
where D: IntoBuf + AsRef<[u8]>,
where
D: IntoBuf + AsRef<[u8]>,
{
type Item = D;
type Error = io::Error;
@ -507,7 +509,7 @@ pub fn encode<T: EncoderHelper + Bits>(input: T) -> Bytes {
#[cfg(test)]
mod tests {
use super::{decode, VarintDecoder, EncoderState};
use super::{decode, EncoderState, VarintDecoder};
use tokio_io::codec::FramedRead;
use num_bigint::BigUint;
use futures::{Future, Stream};