summaryrefslogtreecommitdiff
path: root/lib/rs
diff options
context:
space:
mode:
authorAllen George <allengeorge@apache.org>2020-11-08 09:51:19 -0500
committerAllen George <allengeorge@apache.org>2020-11-12 08:47:42 -0500
commit7ddbcc07ec98349da59bb023d0fed8db37097c18 (patch)
tree80a46fb7f940e8626bfd8f38346f0b85cce368a7 /lib/rs
parent22671db01f5c349f2fa54b393581cb4d61bdd895 (diff)
downloadthrift-7ddbcc07ec98349da59bb023d0fed8db37097c18.tar.gz
THRIFT-5306: Rust code and generated code no longer has clippy warnings (Rust 1.40)
Client: rs NOTE: Also properly update the min/max supported Rust versions
Diffstat (limited to 'lib/rs')
-rw-r--r--lib/rs/Cargo.toml2
-rw-r--r--lib/rs/README.md2
-rw-r--r--lib/rs/src/errors.rs20
-rw-r--r--lib/rs/src/lib.rs8
-rw-r--r--lib/rs/src/protocol/binary.rs22
-rw-r--r--lib/rs/src/protocol/compact.rs52
-rw-r--r--lib/rs/src/protocol/mod.rs20
-rw-r--r--lib/rs/src/protocol/multiplexed.rs2
-rw-r--r--lib/rs/src/protocol/stored.rs2
-rw-r--r--lib/rs/src/server/multiplexed.rs8
-rw-r--r--lib/rs/src/server/threaded.rs2
-rw-r--r--lib/rs/src/transport/buffered.rs10
-rw-r--r--lib/rs/src/transport/mem.rs4
-rw-r--r--lib/rs/test/Cargo.toml4
-rw-r--r--lib/rs/test/src/bin/kitchen_sink_client.rs8
-rw-r--r--lib/rs/test/src/bin/kitchen_sink_server.rs6
-rw-r--r--lib/rs/test/src/lib.rs2
17 files changed, 86 insertions, 88 deletions
diff --git a/lib/rs/Cargo.toml b/lib/rs/Cargo.toml
index 674a4c317..182cd8d86 100644
--- a/lib/rs/Cargo.toml
+++ b/lib/rs/Cargo.toml
@@ -12,8 +12,8 @@ exclude = ["Makefile*", "test/**", "*.iml"]
keywords = ["thrift"]
[dependencies]
-ordered-float = "1.0"
byteorder = "1.3"
integer-encoding = ">=1.1.4" # https://issues.apache.org/jira/browse/THRIFT-5131
log = "0.4"
+ordered-float = "1.0"
threadpool = "1.7"
diff --git a/lib/rs/README.md b/lib/rs/README.md
index 1b608b261..555d219d2 100644
--- a/lib/rs/README.md
+++ b/lib/rs/README.md
@@ -48,7 +48,7 @@ Breaking changes are minimized. When they are made they will be outlined below w
##### Thrift 0.14.0
-* **[THRIFT-5158]** - Rust library and generator now support Rust 2018 only
+* **[THRIFT-5158]** - Rust library and generator now support Rust 2018 only. Required rust 1.40.0 or higher
The Rust `thrift` library was updated to Rust 2018 via `cargo fix --edition`.
All test code in the repo was updated as well. The code generator was also updated
diff --git a/lib/rs/src/errors.rs b/lib/rs/src/errors.rs
index 2167875d4..41a055eca 100644
--- a/lib/rs/src/errors.rs
+++ b/lib/rs/src/errors.rs
@@ -236,8 +236,8 @@ impl Error {
i.read_struct_end()?;
Ok(ApplicationError {
- kind: kind,
- message: message,
+ kind,
+ message,
})
}
@@ -283,7 +283,7 @@ impl error::Error for Error {
}
impl Debug for Error {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
Error::Transport(ref e) => Debug::fmt(e, f),
Error::Protocol(ref e) => Debug::fmt(e, f),
@@ -294,7 +294,7 @@ impl Debug for Error {
}
impl Display for Error {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
Error::Transport(ref e) => Display::fmt(e, f),
Error::Protocol(ref e) => Display::fmt(e, f),
@@ -362,7 +362,7 @@ impl TransportError {
/// Create a new `TransportError`.
pub fn new<S: Into<String>>(kind: TransportErrorKind, message: S) -> TransportError {
TransportError {
- kind: kind,
+ kind,
message: message.into(),
}
}
@@ -404,7 +404,7 @@ impl TransportError {
}
impl Display for TransportError {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.description())
}
}
@@ -490,7 +490,7 @@ impl ProtocolError {
/// Create a new `ProtocolError`.
pub fn new<S: Into<String>>(kind: ProtocolErrorKind, message: S) -> ProtocolError {
ProtocolError {
- kind: kind,
+ kind,
message: message.into(),
}
}
@@ -534,7 +534,7 @@ impl ProtocolError {
}
impl Display for ProtocolError {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.description())
}
}
@@ -581,7 +581,7 @@ impl ApplicationError {
/// Create a new `ApplicationError`.
pub fn new<S: Into<String>>(kind: ApplicationErrorKind, message: S) -> ApplicationError {
ApplicationError {
- kind: kind,
+ kind,
message: message.into(),
}
}
@@ -638,7 +638,7 @@ impl ApplicationError {
}
impl Display for ApplicationError {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.description())
}
}
diff --git a/lib/rs/src/lib.rs b/lib/rs/src/lib.rs
index b762e0577..f71c3e88a 100644
--- a/lib/rs/src/lib.rs
+++ b/lib/rs/src/lib.rs
@@ -49,14 +49,6 @@
#![doc(test(attr(allow(unused_variables), deny(warnings))))]
#![deny(bare_trait_objects)]
-extern crate byteorder;
-extern crate ordered_float;
-extern crate integer_encoding;
-extern crate threadpool;
-
-#[macro_use]
-extern crate log;
-
// NOTE: this macro has to be defined before any modules. See:
// https://danielkeep.github.io/quick-intro-to-macros.html#some-more-gotchas
diff --git a/lib/rs/src/protocol/binary.rs b/lib/rs/src/protocol/binary.rs
index 0ef65e54b..22b496c07 100644
--- a/lib/rs/src/protocol/binary.rs
+++ b/lib/rs/src/protocol/binary.rs
@@ -26,7 +26,7 @@ use super::{TOutputProtocol, TOutputProtocolFactory, TSetIdentifier, TStructIden
use crate::transport::{TReadTransport, TWriteTransport};
use crate::{ProtocolError, ProtocolErrorKind};
-const BINARY_PROTOCOL_VERSION_1: u32 = 0x80010000;
+const BINARY_PROTOCOL_VERSION_1: u32 = 0x8001_0000;
/// Read messages encoded in the Thrift simple binary encoding.
///
@@ -69,8 +69,8 @@ where
/// version number in the protocol header.
pub fn new(transport: T, strict: bool) -> TBinaryInputProtocol<T> {
TBinaryInputProtocol {
- strict: strict,
- transport: transport,
+ strict,
+ transport,
}
}
}
@@ -79,7 +79,7 @@ impl<T> TInputProtocol for TBinaryInputProtocol<T>
where
T: TReadTransport,
{
- #[cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
+ #[allow(clippy::collapsible_if)]
fn read_message_begin(&mut self) -> crate::Result<TMessageIdentifier> {
let mut first_bytes = vec![0; 4];
self.transport.read_exact(&mut first_bytes[..])?;
@@ -295,8 +295,8 @@ where
/// protocol version number in the protocol header.
pub fn new(transport: T, strict: bool) -> TBinaryOutputProtocol<T> {
TBinaryOutputProtocol {
- strict: strict,
- transport: transport,
+ strict,
+ transport,
}
}
}
@@ -520,7 +520,7 @@ mod tests {
let ident = TMessageIdentifier::new("test", TMessageType::Call, 1);
assert!(o_prot.write_message_begin(&ident).is_ok());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 16] = [
0x80,
0x01,
@@ -550,7 +550,7 @@ mod tests {
let ident = TMessageIdentifier::new("test", TMessageType::Call, 1);
assert!(o_prot.write_message_begin(&ident).is_ok());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 13] = [
0x00,
0x00,
@@ -577,7 +577,7 @@ mod tests {
let ident = TMessageIdentifier::new("test", TMessageType::Reply, 10);
assert!(o_prot.write_message_begin(&ident).is_ok());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 16] = [
0x80,
0x01,
@@ -607,7 +607,7 @@ mod tests {
let ident = TMessageIdentifier::new("test", TMessageType::Reply, 10);
assert!(o_prot.write_message_begin(&ident).is_ok());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 13] = [
0x00,
0x00,
@@ -892,7 +892,7 @@ mod tests {
fn must_round_trip_bytes() {
let (mut i_prot, mut o_prot) = test_objects(true);
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let bytes: [u8; 25] = [
0x20,
0xFD,
diff --git a/lib/rs/src/protocol/compact.rs b/lib/rs/src/protocol/compact.rs
index f33c0202a..6fa364fa0 100644
--- a/lib/rs/src/protocol/compact.rs
+++ b/lib/rs/src/protocol/compact.rs
@@ -76,7 +76,7 @@ where
last_read_field_id: 0,
read_field_id_stack: Vec::new(),
pending_read_bool_value: None,
- transport: transport,
+ transport,
}
}
@@ -193,7 +193,7 @@ where
Ok(TFieldIdentifier {
name: None,
- field_type: field_type,
+ field_type,
id: Some(self.last_read_field_id),
})
}
@@ -371,7 +371,7 @@ where
last_write_field_id: 0,
write_field_id_stack: Vec::new(),
pending_write_bool_field_identifier: None,
- transport: transport,
+ transport,
}
}
@@ -673,7 +673,7 @@ mod tests {
431
)));
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 8] = [
0x82, /* protocol ID */
0x21, /* message type | protocol version */
@@ -695,10 +695,10 @@ mod tests {
assert_success!(o_prot.write_message_begin(&TMessageIdentifier::new(
"bar",
TMessageType::Reply,
- 991828
+ 991_828
)));
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 9] = [
0x82, /* protocol ID */
0x41, /* message type | protocol version */
@@ -743,7 +743,7 @@ mod tests {
fn must_round_trip_message_begin() {
let (mut i_prot, mut o_prot) = test_objects();
- let ident = TMessageIdentifier::new("service_call", TMessageType::Call, 1283948);
+ let ident = TMessageIdentifier::new("service_call", TMessageType::Call, 1_283_948);
assert_success!(o_prot.write_message_begin(&ident));
@@ -787,7 +787,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 5] = [
0x03, /* field type */
0x00, /* first field id */
@@ -902,7 +902,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 4] = [
0x15, /* field delta (1) | field type */
0x1A, /* field delta (1) | field type */
@@ -1015,7 +1015,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 8] = [
0x05, /* field type */
0x00, /* first field id */
@@ -1139,7 +1139,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 10] = [
0x16, /* field delta (1) | field type */
0x85, /* field delta (8) | field type */
@@ -1156,6 +1156,7 @@ mod tests {
assert_eq_written_bytes!(o_prot, expected);
}
+ #[allow(clippy::cognitive_complexity)]
#[test]
fn must_round_trip_struct_with_mix_of_long_and_delta_fields() {
let (mut i_prot, mut o_prot) = test_objects();
@@ -1304,7 +1305,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 7] = [
0x16, /* field delta (1) | field type */
0x85, /* field delta (8) | field type */
@@ -1318,6 +1319,7 @@ mod tests {
assert_eq_written_bytes!(o_prot, expected);
}
+ #[allow(clippy::cognitive_complexity)]
#[test]
fn must_round_trip_nested_structs_0() {
// last field of the containing struct is a delta
@@ -1477,7 +1479,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 7] = [
0x16, /* field delta (1) | field type */
0x85, /* field delta (8) | field type */
@@ -1491,6 +1493,7 @@ mod tests {
assert_eq_written_bytes!(o_prot, expected);
}
+ #[allow(clippy::cognitive_complexity)]
#[test]
fn must_round_trip_nested_structs_1() {
// last field of the containing struct is a delta
@@ -1650,7 +1653,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 7] = [
0x16, /* field delta (1) | field type */
0x08, /* field type */
@@ -1664,6 +1667,7 @@ mod tests {
assert_eq_written_bytes!(o_prot, expected);
}
+ #[allow(clippy::cognitive_complexity)]
#[test]
fn must_round_trip_nested_structs_2() {
let (mut i_prot, mut o_prot) = test_objects();
@@ -1820,7 +1824,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 8] = [
0x16, /* field delta (1) | field type */
0x08, /* field type */
@@ -1835,6 +1839,7 @@ mod tests {
assert_eq_written_bytes!(o_prot, expected);
}
+ #[allow(clippy::cognitive_complexity)]
#[test]
fn must_round_trip_nested_structs_3() {
// last field of the containing struct is a full write
@@ -1986,7 +1991,7 @@ mod tests {
assert_success!(o_prot.write_field_stop());
assert_success!(o_prot.write_struct_end());
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 7] = [
0x11, /* field delta (1) | true */
0x82, /* field delta (8) | false */
@@ -2000,6 +2005,7 @@ mod tests {
assert_eq_written_bytes!(o_prot, expected);
}
+ #[allow(clippy::cognitive_complexity)]
#[test]
fn must_round_trip_bool_field() {
let (mut i_prot, mut o_prot) = test_objects();
@@ -2245,7 +2251,7 @@ mod tests {
fn must_round_trip_large_sized_set_begin() {
let (mut i_prot, mut o_prot) = test_objects();
- let ident = TSetIdentifier::new(TType::Map, 3928429);
+ let ident = TSetIdentifier::new(TType::Map, 3_928_429);
assert_success!(o_prot.write_set_begin(&ident));
@@ -2312,7 +2318,7 @@ mod tests {
fn must_round_trip_map_begin() {
let (mut i_prot, mut o_prot) = test_objects();
- let ident = TMapIdentifier::new(TType::Map, TType::List, 1928349);
+ let ident = TMapIdentifier::new(TType::Map, TType::List, 1_928_349);
assert_success!(o_prot.write_map_begin(&ident));
@@ -2403,11 +2409,13 @@ mod tests {
fn must_read_write_double() {
let (mut i_prot, mut o_prot) = test_objects();
- let double = 3.141592653589793238462643;
+ #[allow(clippy::approx_constant)]
+ let double = 3.141_592_653_589_793;
o_prot.write_double(double).unwrap();
copy_write_buffer_to_read_buffer!(o_prot);
- assert_eq!(i_prot.read_double().unwrap(), double);
+ let read_double = i_prot.read_double().unwrap();
+ assert!(read_double - double < std::f64::EPSILON);
}
#[test]
@@ -2415,11 +2423,11 @@ mod tests {
let (_, mut o_prot) = test_objects();
let expected = [24, 45, 68, 84, 251, 33, 9, 64];
- let double = 3.141592653589793238462643;
+ #[allow(clippy::approx_constant)]
+ let double = 3.141_592_653_589_793;
o_prot.write_double(double).unwrap();
assert_eq_written_bytes!(o_prot, expected);
-
}
fn assert_no_write<F>(mut write_fn: F)
diff --git a/lib/rs/src/protocol/mod.rs b/lib/rs/src/protocol/mod.rs
index b0e9118ce..f9c1f724c 100644
--- a/lib/rs/src/protocol/mod.rs
+++ b/lib/rs/src/protocol/mod.rs
@@ -610,8 +610,8 @@ impl TMessageIdentifier {
) -> TMessageIdentifier {
TMessageIdentifier {
name: name.into(),
- message_type: message_type,
- sequence_number: sequence_number,
+ message_type,
+ sequence_number,
}
}
}
@@ -660,7 +660,7 @@ impl TFieldIdentifier {
{
TFieldIdentifier {
name: name.into().map(|n| n.into()),
- field_type: field_type,
+ field_type,
id: id.into(),
}
}
@@ -680,8 +680,8 @@ impl TListIdentifier {
/// `element_type`.
pub fn new(element_type: TType, size: i32) -> TListIdentifier {
TListIdentifier {
- element_type: element_type,
- size: size,
+ element_type,
+ size,
}
}
}
@@ -700,8 +700,8 @@ impl TSetIdentifier {
/// `element_type`.
pub fn new(element_type: TType, size: i32) -> TSetIdentifier {
TSetIdentifier {
- element_type: element_type,
- size: size,
+ element_type,
+ size,
}
}
}
@@ -728,7 +728,7 @@ impl TMapIdentifier {
TMapIdentifier {
key_type: key_type.into(),
value_type: value_type.into(),
- size: size,
+ size,
}
}
}
@@ -747,7 +747,7 @@ pub enum TMessageType {
}
impl Display for TMessageType {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
TMessageType::Call => write!(f, "Call"),
TMessageType::Reply => write!(f, "Reply"),
@@ -822,7 +822,7 @@ pub enum TType {
}
impl Display for TType {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
TType::Stop => write!(f, "STOP"),
TType::Void => write!(f, "void"),
diff --git a/lib/rs/src/protocol/multiplexed.rs b/lib/rs/src/protocol/multiplexed.rs
index 9c3ba7c20..83498fbdd 100644
--- a/lib/rs/src/protocol/multiplexed.rs
+++ b/lib/rs/src/protocol/multiplexed.rs
@@ -203,7 +203,7 @@ mod tests {
let ident = TMessageIdentifier::new("bar", TMessageType::Call, 2);
assert_success!(o_prot.write_message_begin(&ident));
- #[cfg_attr(rustfmt, rustfmt::skip)]
+ #[rustfmt::skip]
let expected: [u8; 19] = [
0x80,
0x01, /* protocol identifier */
diff --git a/lib/rs/src/protocol/stored.rs b/lib/rs/src/protocol/stored.rs
index c5e02fea0..179ae07b0 100644
--- a/lib/rs/src/protocol/stored.rs
+++ b/lib/rs/src/protocol/stored.rs
@@ -92,7 +92,7 @@ impl<'a> TStoredInputProtocol<'a> {
pub fn new(
wrapped: &mut dyn TInputProtocol,
message_ident: TMessageIdentifier,
- ) -> TStoredInputProtocol {
+ ) -> TStoredInputProtocol<'_> {
TStoredInputProtocol {
inner: wrapped,
message_ident: message_ident.into(),
diff --git a/lib/rs/src/server/multiplexed.rs b/lib/rs/src/server/multiplexed.rs
index 3d688fa20..4f41f2447 100644
--- a/lib/rs/src/server/multiplexed.rs
+++ b/lib/rs/src/server/multiplexed.rs
@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.
+use log::debug;
+
use std::collections::HashMap;
use std::convert::Into;
use std::fmt;
@@ -25,7 +27,7 @@ use crate::protocol::{TInputProtocol, TMessageIdentifier, TOutputProtocol, TStor
use super::{handle_process_result, TProcessor};
-const MISSING_SEPARATOR_AND_NO_DEFAULT: &'static str =
+const MISSING_SEPARATOR_AND_NO_DEFAULT: &str =
"missing service separator and no default processor set";
type ThreadSafeProcessor = Box<dyn TProcessor + Send + Sync>;
@@ -70,7 +72,7 @@ impl TMultiplexedProcessor {
/// Returns success if a new entry was inserted. Returns an error if:
/// * A processor exists for `service_name`
/// * You attempt to register a processor as default, and an existing default exists
- #[cfg_attr(feature = "cargo-clippy", allow(map_entry))]
+ #[allow(clippy::map_entry)]
pub fn register<S: Into<String>>(
&mut self,
service_name: S,
@@ -145,7 +147,7 @@ impl TProcessor for TMultiplexedProcessor {
}
impl Debug for TMultiplexedProcessor {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let stored = self.stored.lock().unwrap();
write!(
f,
diff --git a/lib/rs/src/server/threaded.rs b/lib/rs/src/server/threaded.rs
index 8373c469c..64bf8bbe5 100644
--- a/lib/rs/src/server/threaded.rs
+++ b/lib/rs/src/server/threaded.rs
@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.
+use log::warn;
+
use std::net::{TcpListener, TcpStream, ToSocketAddrs};
use std::sync::Arc;
use threadpool::ThreadPool;
diff --git a/lib/rs/src/transport/buffered.rs b/lib/rs/src/transport/buffered.rs
index 914a19b6f..ebdcdc292 100644
--- a/lib/rs/src/transport/buffered.rs
+++ b/lib/rs/src/transport/buffered.rs
@@ -200,7 +200,7 @@ where
TBufferedWriteTransport {
buf: Vec::with_capacity(write_capacity),
cap: write_capacity,
- channel: channel,
+ channel,
}
}
}
@@ -347,8 +347,8 @@ mod tests {
// fill the underlying transport's byte buffer
let mut readable_bytes = [0u8; 10];
- for i in 0..10 {
- readable_bytes[i] = i as u8;
+ for (i, b) in readable_bytes.iter_mut().enumerate() {
+ *b = i as u8;
}
t.chan.set_readable_bytes(&readable_bytes);
@@ -365,8 +365,8 @@ mod tests {
assert_eq!(&buf, &[0, 1, 2, 3, 4, 5, 6, 7]);
// let's clear out the buffer and try read again
- for i in 0..8 {
- buf[i] = 0;
+ for b in &mut buf{
+ *b = 0;
}
let read_result = t.read(&mut buf);
diff --git a/lib/rs/src/transport/mem.rs b/lib/rs/src/transport/mem.rs
index 68fb2652e..fe1c54346 100644
--- a/lib/rs/src/transport/mem.rs
+++ b/lib/rs/src/transport/mem.rs
@@ -153,7 +153,9 @@ impl TIoChannel for TBufferChannel {
WriteHalf {
handle: TBufferChannel {
read: self.read.clone(),
- write: self.write.clone(),
+ // NOTE: not cloning here, since this is the last statement
+ // in this method and `write` can take ownership of `self.write`
+ write: self.write,
},
},
))
diff --git a/lib/rs/test/Cargo.toml b/lib/rs/test/Cargo.toml
index decc985d8..9341bd563 100644
--- a/lib/rs/test/Cargo.toml
+++ b/lib/rs/test/Cargo.toml
@@ -7,9 +7,7 @@ authors = ["Apache Thrift Developers <dev@thrift.apache.org>"]
publish = false
[dependencies]
-clap = "<2.28.0"
-ordered-float = "1.0"
-try_from = "0.3"
+clap = "2.33"
[dependencies.thrift]
path = "../"
diff --git a/lib/rs/test/src/bin/kitchen_sink_client.rs b/lib/rs/test/src/bin/kitchen_sink_client.rs
index a7779203d..74197de7f 100644
--- a/lib/rs/test/src/bin/kitchen_sink_client.rs
+++ b/lib/rs/test/src/bin/kitchen_sink_client.rs
@@ -15,11 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#[macro_use]
-extern crate clap;
-
-extern crate kitchen_sink;
-extern crate thrift;
+use clap::{clap_app, value_t};
use std::convert::Into;
@@ -28,6 +24,8 @@ use kitchen_sink::midlayer::{MealServiceSyncClient, TMealServiceSyncClient};
use kitchen_sink::recursive;
use kitchen_sink::recursive::{CoRec, CoRec2, RecList, RecTree, TTestServiceSyncClient};
use kitchen_sink::ultimate::{FullMealServiceSyncClient, TFullMealServiceSyncClient};
+
+use thrift;
use thrift::protocol::{
TBinaryInputProtocol, TBinaryOutputProtocol, TCompactInputProtocol, TCompactOutputProtocol,
TInputProtocol, TOutputProtocol,
diff --git a/lib/rs/test/src/bin/kitchen_sink_server.rs b/lib/rs/test/src/bin/kitchen_sink_server.rs
index c53e887f9..6df39e4bc 100644
--- a/lib/rs/test/src/bin/kitchen_sink_server.rs
+++ b/lib/rs/test/src/bin/kitchen_sink_server.rs
@@ -15,11 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-#[macro_use]
-extern crate clap;
-extern crate kitchen_sink;
-extern crate thrift;
+use clap::{clap_app, value_t};
+use thrift;
use thrift::protocol::{
TBinaryInputProtocolFactory, TBinaryOutputProtocolFactory, TCompactInputProtocolFactory,
TCompactOutputProtocolFactory, TInputProtocolFactory, TOutputProtocolFactory,
diff --git a/lib/rs/test/src/lib.rs b/lib/rs/test/src/lib.rs
index 9debdca54..91fd02728 100644
--- a/lib/rs/test/src/lib.rs
+++ b/lib/rs/test/src/lib.rs
@@ -15,8 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-extern crate thrift;
-
pub mod base_one;
pub mod base_two;
pub mod midlayer;