TryFrom stable
TryFrom is now stable, so use that. Additionally re-export OrderedFloat since
it is used by the generated code. Relax dependencies to reduce downstream
conflicts.
diff --git a/lib/rs/Cargo.toml b/lib/rs/Cargo.toml
index 3a25b16..bad2a38 100644
--- a/lib/rs/Cargo.toml
+++ b/lib/rs/Cargo.toml
@@ -11,9 +11,8 @@
keywords = ["thrift"]
[dependencies]
-byteorder = "~1.2.1"
-integer-encoding = "~1.0.4"
-log = "~0.3.8"
-threadpool = "~1.7.1"
-try_from = "~0.2.2"
-
+ordered-float = "0.5"
+byteorder = "1"
+integer-encoding = "1"
+log = "0.4"
+threadpool = "1.7"
diff --git a/lib/rs/src/errors.rs b/lib/rs/src/errors.rs
index 16a2576..6fb1aee 100644
--- a/lib/rs/src/errors.rs
+++ b/lib/rs/src/errors.rs
@@ -19,7 +19,7 @@
use std::error::Error as StdError;
use std::fmt::{Debug, Display, Formatter};
use std::{error, fmt, io, string};
-use try_from::TryFrom;
+use std::convert::TryFrom;
use protocol::{TFieldIdentifier, TInputProtocol, TOutputProtocol, TStructIdentifier, TType};
@@ -413,8 +413,8 @@
}
impl TryFrom<i32> for TransportErrorKind {
- type Err = Error;
- fn try_from(from: i32) -> Result<Self, Self::Err> {
+ type Error = Error;
+ fn try_from(from: i32) -> Result<Self, Self::Error> {
match from {
0 => Ok(TransportErrorKind::Unknown),
1 => Ok(TransportErrorKind::NotOpen),
@@ -543,8 +543,8 @@
}
impl TryFrom<i32> for ProtocolErrorKind {
- type Err = Error;
- fn try_from(from: i32) -> Result<Self, Self::Err> {
+ type Error = Error;
+ fn try_from(from: i32) -> Result<Self, Self::Error> {
match from {
0 => Ok(ProtocolErrorKind::Unknown),
1 => Ok(ProtocolErrorKind::InvalidData),
@@ -647,8 +647,8 @@
}
impl TryFrom<i32> for ApplicationErrorKind {
- type Err = Error;
- fn try_from(from: i32) -> Result<Self, Self::Err> {
+ type Error = Error;
+ fn try_from(from: i32) -> Result<Self, Self::Error> {
match from {
0 => Ok(ApplicationErrorKind::Unknown),
1 => Ok(ApplicationErrorKind::UnknownMethod),
diff --git a/lib/rs/src/lib.rs b/lib/rs/src/lib.rs
index ca5c7d6..a36ec99 100644
--- a/lib/rs/src/lib.rs
+++ b/lib/rs/src/lib.rs
@@ -49,9 +49,9 @@
#![doc(test(attr(allow(unused_variables), deny(warnings))))]
extern crate byteorder;
+extern crate ordered_float;
extern crate integer_encoding;
extern crate threadpool;
-extern crate try_from;
#[macro_use]
extern crate log;
@@ -85,3 +85,6 @@
/// As is convention this is a typedef of `std::result::Result`
/// with `E` defined as the `thrift::Error` type.
pub type Result<T> = std::result::Result<T, self::Error>;
+
+// Re-export ordered-float, since it is used by the generator
+pub use ordered_float::OrderedFloat as OrderedFloat;
\ No newline at end of file
diff --git a/lib/rs/src/protocol/binary.rs b/lib/rs/src/protocol/binary.rs
index 19aff3d..0920fc4 100644
--- a/lib/rs/src/protocol/binary.rs
+++ b/lib/rs/src/protocol/binary.rs
@@ -16,8 +16,7 @@
// under the License.
use byteorder::{BigEndian, ByteOrder, ReadBytesExt, WriteBytesExt};
-use std::convert::From;
-use try_from::TryFrom;
+use std::convert::{From, TryFrom};
use super::{
TFieldIdentifier, TInputProtocol, TInputProtocolFactory, TListIdentifier, TMapIdentifier,
diff --git a/lib/rs/src/protocol/compact.rs b/lib/rs/src/protocol/compact.rs
index df5edaa..334e820 100644
--- a/lib/rs/src/protocol/compact.rs
+++ b/lib/rs/src/protocol/compact.rs
@@ -17,9 +17,8 @@
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use integer_encoding::{VarIntReader, VarIntWriter};
-use std::convert::From;
+use std::convert::{From, TryFrom};
use std::io;
-use try_from::TryFrom;
use super::{
TFieldIdentifier, TInputProtocol, TInputProtocolFactory, TListIdentifier, TMapIdentifier,
diff --git a/lib/rs/src/protocol/mod.rs b/lib/rs/src/protocol/mod.rs
index 11c0289..1ab1658 100644
--- a/lib/rs/src/protocol/mod.rs
+++ b/lib/rs/src/protocol/mod.rs
@@ -57,10 +57,9 @@
//! protocol.write_field_end().unwrap();
//! ```
-use std::convert::From;
+use std::convert::{From, TryFrom};
use std::fmt;
use std::fmt::{Display, Formatter};
-use try_from::TryFrom;
use transport::{TReadTransport, TWriteTransport};
use {ProtocolError, ProtocolErrorKind};
@@ -770,8 +769,8 @@
}
impl TryFrom<u8> for TMessageType {
- type Err = ::Error;
- fn try_from(b: u8) -> ::Result<Self> {
+ type Error = ::Error;
+ fn try_from(b: u8) -> Result<Self, Self::Error> {
match b {
0x01 => Ok(TMessageType::Call),
0x02 => Ok(TMessageType::Reply),
diff --git a/lib/rs/test/src/lib.rs b/lib/rs/test/src/lib.rs
index e5e176e..9debdca 100644
--- a/lib/rs/test/src/lib.rs
+++ b/lib/rs/test/src/lib.rs
@@ -15,9 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-extern crate ordered_float;
extern crate thrift;
-extern crate try_from;
pub mod base_one;
pub mod base_two;