Skip to content

Commit 17db0dd

Browse files
committed
Drop unnecessary num-traits
1 parent 7bccc8c commit 17db0dd

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

rmp-serde/tests/round.rs

+2
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
508508

509509
#[test]
510510
fn roundtrip_tuples_arrays() {
511+
assert_roundtrips(Some::<[u8; 0]>([]));
512+
assert_roundtrips(Some(Some::<[u8; 0]>([])));
511513
assert_roundtrips((1i32,100,1000,10000,100000,1000000,10000000));
512514
assert_roundtrips((0u8,1u8,11u8,111u8,255u8));
513515
assert_roundtrips((0u8,1i8,11u16,111i32,255i64));

rmpv/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ with-serde = ["serde", "serde_bytes"]
1818
[dependencies]
1919
serde_bytes = { version = "0.11.5", optional = true }
2020
rmp = { version = "0.8.14", path = "../rmp" }
21-
num-traits = "0.2.14"
2221
serde = { version = "1.0.197", optional = true }
2322

2423
[dev-dependencies]

rmpv/src/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use std::iter::FromIterator;
88
use std::ops::Index;
99
use std::str::Utf8Error;
1010

11-
use num_traits::NumCast;
12-
1311
pub mod decode;
1412
pub mod encode;
1513

@@ -73,7 +71,7 @@ impl Integer {
7371
#[must_use]
7472
pub fn as_i64(&self) -> Option<i64> {
7573
match self.n {
76-
IntPriv::PosInt(n) => NumCast::from(n),
74+
IntPriv::PosInt(n) => n.try_into().ok(),
7775
IntPriv::NegInt(n) => Some(n),
7876
}
7977
}
@@ -84,7 +82,7 @@ impl Integer {
8482
pub fn as_u64(&self) -> Option<u64> {
8583
match self.n {
8684
IntPriv::PosInt(n) => Some(n),
87-
IntPriv::NegInt(n) => NumCast::from(n),
85+
IntPriv::NegInt(n) => n.try_into().ok(),
8886
}
8987
}
9088

@@ -93,8 +91,8 @@ impl Integer {
9391
#[must_use]
9492
pub fn as_f64(&self) -> Option<f64> {
9593
match self.n {
96-
IntPriv::PosInt(n) => NumCast::from(n),
97-
IntPriv::NegInt(n) => NumCast::from(n),
94+
IntPriv::PosInt(n) => Some(n as _),
95+
IntPriv::NegInt(n) => Some(n as _),
9896
}
9997
}
10098
}

0 commit comments

Comments
 (0)