Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/pyfisch/cbor
Browse files Browse the repository at this point in the history
  • Loading branch information
pyfisch committed Sep 7, 2019
2 parents e03ecc9 + 86a8fe3 commit d27e97d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ before_script:
- rustup target add thumbv7em-none-eabihf # Any target that does not have a standard library will do
script:
- cargo fmt --all -- --check
- (rustup component add clippy && cargo clippy --all --all-features -- -D clippy::all) || true
- cargo build
- cargo test
- cargo build --no-default-features --target thumbv7em-none-eabihf # Test we can build a platform that does not have std.
Expand Down
3 changes: 2 additions & 1 deletion src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ where
}

/// Turn a CBOR deserializer into an iterator over values of type T.
#[allow(clippy::should_implement_trait)] // Trait doesn't allow unconstrained T.
pub fn into_iter<T>(self) -> StreamDeserializer<'de, R, T>
where
T: de::Deserialize<'de>,
Expand Down Expand Up @@ -599,7 +600,7 @@ where
0x3b => {
let value = self.parse_u64()?;
if value > i64::max_value() as u64 {
return visitor.visit_i128(-1 - value as i128);
return visitor.visit_i128(-1 - i128::from(value));
}
visitor.visit_i64(-1 - value as i64)
}
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Error {
pub fn scratch_too_small(offset: u64) -> Error {
Error(ErrorImpl {
code: ErrorCode::ScratchTooSmall,
offset: offset,
offset,
})
}

Expand Down
8 changes: 4 additions & 4 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
#[inline]
pub fn new(writer: W) -> Self {
Serializer {
writer: writer,
writer,
packed: false,
enum_as_map: true,
}
Expand Down Expand Up @@ -263,12 +263,12 @@ where
#[inline]
fn serialize_i128(self, value: i128) -> Result<()> {
if value < 0 {
if -(value + 1) > u64::max_value() as i128 {
if -(value + 1) > i128::from(u64::max_value()) {
return Err(Error::message("The number can't be stored in CBOR"));
}
self.write_u64(1, -(value + 1) as u64)
} else {
if value > u64::max_value() as i128 {
if value > i128::from(u64::max_value()) {
return Err(Error::message("The number can't be stored in CBOR"));
}
self.write_u64(0, value as u64)
Expand Down Expand Up @@ -297,7 +297,7 @@ where

#[inline]
fn serialize_u128(self, value: u128) -> Result<()> {
if value > u64::max_value() as u128 {
if value > u128::from(u64::max_value()) {
return Err(Error::message("The number can't be stored in CBOR"));
}
self.write_u64(0, value as u64)
Expand Down
2 changes: 1 addition & 1 deletion src/value/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl serde::ser::SerializeMap for SerializeMap {
where
T: Serialize,
{
self.next_key = Some(Value::from(to_value(&key)?));
self.next_key = Some(to_value(&key)?);
Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion tests/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,5 +725,4 @@ mod std_tests {
let deserialized_ip = from_slice::<IpAddr>(&buf).unwrap();
assert_eq!(ip, deserialized_ip);
}

}

0 comments on commit d27e97d

Please sign in to comment.