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
diff --git a/lib/rs/src/transport/buffered.rs b/lib/rs/src/transport/buffered.rs
index 914a19b..ebdcdc2 100644
--- a/lib/rs/src/transport/buffered.rs
+++ b/lib/rs/src/transport/buffered.rs
@@ -200,7 +200,7 @@
TBufferedWriteTransport {
buf: Vec::with_capacity(write_capacity),
cap: write_capacity,
- channel: channel,
+ channel,
}
}
}
@@ -347,8 +347,8 @@
// 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 @@
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 68fb265..fe1c543 100644
--- a/lib/rs/src/transport/mem.rs
+++ b/lib/rs/src/transport/mem.rs
@@ -153,7 +153,9 @@
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,
},
},
))