diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000..916c6bb
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,95 @@
+name: CI
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ check:
+ name: Check
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ rust:
+ - stable
+ - beta
+ - nightly
+ - 1.18.0 # MSRV
+
+ steps:
+ - uses: actions/checkout@v2
+ name: Checkout
+
+ - uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust }}
+ override: true
+ name: Install Rust ${{ matrix.rust }}
+
+ - uses: actions-rs/cargo@v1
+ with:
+ command: check
+ name: Run `cargo check`
+
+ - uses: actions-rs/cargo@v1
+ with:
+ command: check
+ args: --examples
+ name: Check examples
+ if: matrix.rust != '1.18.0'
+
+ test:
+ name: Test
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ rust:
+ - stable
+ - beta
+ - nightly
+ steps:
+ - uses: actions/checkout@v2
+ name: Checkout
+
+ - uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust }}
+ override: true
+ name: Install Rust ${{ matrix.rust }}
+
+ - uses: actions-rs/cargo@v1
+ with:
+ command: test
+ name: Run `cargo test`
+
+ lints:
+ name: Lints
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ name: Checkout
+
+ - uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ override: true
+ components: rustfmt, clippy
+ name: Install Rust stable
+
+ - uses: actions-rs/cargo@v1
+ with:
+ command: fmt
+ args: --all -- --check
+ name: Run `cargo fmt`
+
+ - uses: actions-rs/cargo@v1
+ with:
+ command: clippy
+ args: -- -D warnings
+ name: Run `cargo clippy`
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index f9a012a..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-language: rust
-
-rust:
- - stable
- - beta
- - nightly
-
-script:
- - cargo test
- - cargo package
- - cd target/package/bincode-* && cargo test
-
-matrix:
- include:
- - rust: 1.18.0
- script: cargo build
diff --git a/README.md b/README.md
index 579332b..cf282a3 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-[](https://travis-ci.com/servo/bincode)
+
[](https://crates.io/crates/bincode)
[](https://opensource.org/licenses/MIT)
diff --git a/src/config.rs b/src/config.rs
index fc19ac3..d8ca050 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -125,7 +125,7 @@ impl WithOtherEndian {
#[inline(always)]
pub(crate) fn new(options: O) -> WithOtherEndian {
WithOtherEndian {
- options: options,
+ options,
_endian: PhantomData,
}
}
diff --git a/src/de/mod.rs b/src/de/mod.rs
index 0a754e9..7db35e4 100644
--- a/src/de/mod.rs
+++ b/src/de/mod.rs
@@ -32,10 +32,7 @@ pub(crate) struct Deserializer {
impl<'de, R: BincodeRead<'de>, O: Options> Deserializer {
/// Creates a new Deserializer with a given `Read`er and a size_limit.
pub(crate) fn new(r: R, options: O) -> Deserializer {
- Deserializer {
- reader: r,
- options: options,
- }
+ Deserializer { reader: r, options }
}
fn read_bytes(&mut self, count: u64) -> Result<()> {
@@ -149,7 +146,7 @@ where
let mut buf = [0u8; 4];
// Look at the first byte to see how many bytes must be read
- let _ = self.reader.read_exact(&mut buf[..1])?;
+ self.reader.read_exact(&mut buf[..1])?;
let width = utf8_char_width(buf[0]);
if width == 1 {
return visitor.visit_char(buf[0] as char);
@@ -163,9 +160,9 @@ where
}
let res = str::from_utf8(&buf[..width])
- .ok()
- .and_then(|s| s.chars().next())
- .ok_or(error())?;
+ .ok()
+ .and_then(|s| s.chars().next())
+ .ok_or_else(error)?;
visitor.visit_char(res)
}
@@ -251,10 +248,8 @@ where
{
if self.len > 0 {
self.len -= 1;
- let value = serde::de::DeserializeSeed::deserialize(
- seed,
- &mut *self.deserializer,
- )?;
+ let value =
+ serde::de::DeserializeSeed::deserialize(seed, &mut *self.deserializer)?;
Ok(Some(value))
} else {
Ok(None)
@@ -268,7 +263,7 @@ where
visitor.visit_seq(Access {
deserializer: self,
- len: len,
+ len,
})
}
@@ -313,10 +308,8 @@ where
{
if self.len > 0 {
self.len -= 1;
- let key = serde::de::DeserializeSeed::deserialize(
- seed,
- &mut *self.deserializer,
- )?;
+ let key =
+ serde::de::DeserializeSeed::deserialize(seed, &mut *self.deserializer)?;
Ok(Some(key))
} else {
Ok(None)
@@ -327,10 +320,7 @@ where
where
V: serde::de::DeserializeSeed<'de>,
{
- let value = serde::de::DeserializeSeed::deserialize(
- seed,
- &mut *self.deserializer,
- )?;
+ let value = serde::de::DeserializeSeed::deserialize(seed, &mut *self.deserializer)?;
Ok(value)
}
@@ -343,7 +333,7 @@ where
visitor.visit_map(Access {
deserializer: self,
- len: len,
+ len,
})
}
diff --git a/src/de/read.rs b/src/de/read.rs
index 107ce01..6177eba 100644
--- a/src/de/read.rs
+++ b/src/de/read.rs
@@ -1,6 +1,6 @@
use error::Result;
use serde;
-use std::{io, slice};
+use std::io;
/// An optional Read trait for advanced Bincode usage.
///
@@ -77,13 +77,13 @@ impl<'storage> io::Read for SliceReader<'storage> {
let (read_slice, remaining) = self.slice.split_at(out.len());
out.copy_from_slice(read_slice);
self.slice = remaining;
-
+
Ok(out.len())
}
#[inline(always)]
fn read_exact(&mut self, out: &mut [u8]) -> io::Result<()> {
- self.read(out).map(|_|())
+ self.read(out).map(|_| ())
}
}
@@ -101,10 +101,10 @@ impl io::Read for IoReader {
impl<'storage> SliceReader<'storage> {
#[inline(always)]
fn unexpected_eof() -> Box<::ErrorKind> {
- return Box::new(::ErrorKind::Io(io::Error::new(
+ Box::new(::ErrorKind::Io(io::Error::new(
io::ErrorKind::UnexpectedEof,
"",
- )));
+ )))
}
}
diff --git a/src/lib.rs b/src/lib.rs
index cf7107b..2c12498 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,5 @@
#![deny(missing_docs)]
+#![allow(unknown_lints, bare_trait_objects, deprecated)]
//! Bincode is a crate for encoding and decoding using a tiny binary
//! serialization strategy. Using it, you can easily go from having
diff --git a/src/ser/mod.rs b/src/ser/mod.rs
index da568b1..f353d60 100644
--- a/src/ser/mod.rs
+++ b/src/ser/mod.rs
@@ -224,10 +224,6 @@ pub(crate) struct SizeChecker {
}
impl SizeChecker {
- pub fn new(options: O) -> SizeChecker {
- SizeChecker { options: options }
- }
-
fn add_raw(&mut self, size: u64) -> Result<()> {
self.options.limit().add(size)
}
@@ -755,7 +751,7 @@ fn encode_utf8(c: char) -> EncodeUtf8 {
buf[3] = (code & 0x3F) as u8 | TAG_CONT;
0
};
- EncodeUtf8 { buf: buf, pos: pos }
+ EncodeUtf8 { buf, pos }
}
struct EncodeUtf8 {
diff --git a/tests/test.rs b/tests/test.rs
index e64138a..ffe81d0 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -334,12 +334,10 @@ fn test_serialized_size_bounded() {
assert!(config().limit(7).serialized_size(&0u64).is_err());
assert!(config().limit(7).serialized_size(&"").is_err());
assert!(config().limit(8 + 0).serialized_size(&"a").is_err());
- assert!(
- config()
- .limit(8 + 3 * 4 - 1)
- .serialized_size(&vec![0u32, 1u32, 2u32])
- .is_err()
- );
+ assert!(config()
+ .limit(8 + 3 * 4 - 1)
+ .serialized_size(&vec![0u32, 1u32, 2u32])
+ .is_err());
}
#[test]
@@ -423,7 +421,8 @@ fn test_oom_protection() {
.serialize(&FakeVec {
len: 0xffffffffffffffffu64,
byte: 1,
- }).unwrap();
+ })
+ .unwrap();
let y: Result> = config()
.limit(10)
.deserialize_from(&mut Cursor::new(&x[..]));
@@ -581,7 +580,8 @@ fn test_zero_copy_parse_deserialize_into() {
slice: &encoded[..],
},
&mut target,
- ).unwrap();
+ )
+ .unwrap();
assert_eq!(target, f);
}
}