Reformat rust code using 1.40 rustfmt and fail build if rustfmt fails (#2339)
diff --git a/lib/rs/src/protocol/binary.rs b/lib/rs/src/protocol/binary.rs
index 22b496c..8509c34 100644
--- a/lib/rs/src/protocol/binary.rs
+++ b/lib/rs/src/protocol/binary.rs
@@ -68,10 +68,7 @@
/// Set `strict` to `true` if all incoming messages contain the protocol
/// version number in the protocol header.
pub fn new(transport: T, strict: bool) -> TBinaryInputProtocol<T> {
- TBinaryInputProtocol {
- strict,
- transport,
- }
+ TBinaryInputProtocol { strict, transport }
}
}
@@ -294,10 +291,7 @@
/// Set `strict` to `true` if all outgoing messages should contain the
/// protocol version number in the protocol header.
pub fn new(transport: T, strict: bool) -> TBinaryOutputProtocol<T> {
- TBinaryOutputProtocol {
- strict,
- transport,
- }
+ TBinaryOutputProtocol { strict, transport }
}
}
@@ -453,7 +447,10 @@
}
impl TOutputProtocolFactory for TBinaryOutputProtocolFactory {
- fn create(&self, transport: Box<dyn TWriteTransport + Send>) -> Box<dyn TOutputProtocol + Send> {
+ fn create(
+ &self,
+ transport: Box<dyn TWriteTransport + Send>,
+ ) -> Box<dyn TOutputProtocol + Send> {
Box::new(TBinaryOutputProtocol::new(transport, true))
}
}
diff --git a/lib/rs/src/protocol/compact.rs b/lib/rs/src/protocol/compact.rs
index f885e40..e08a30b 100644
--- a/lib/rs/src/protocol/compact.rs
+++ b/lib/rs/src/protocol/compact.rs
@@ -427,7 +427,8 @@
self.write_byte(COMPACT_PROTOCOL_ID)?;
self.write_byte((u8::from(identifier.message_type) << 5) | COMPACT_VERSION)?;
// cast i32 as u32 so that varint writing won't use zigzag encoding
- self.transport.write_varint(identifier.sequence_number as u32)?;
+ self.transport
+ .write_varint(identifier.sequence_number as u32)?;
self.write_string(&identifier.name)?;
Ok(())
}
@@ -1091,6 +1092,7 @@
let (mut i_prot, _) = test_objects();
// signed two's complement of -1073741823 = 1100_0000_0000_0000_0000_0000_0000_0001
+ #[rustfmt::skip]
let source_bytes: [u8; 11] = [
0x82, /* protocol ID */
0x21, /* message type | protocol version */
@@ -1102,7 +1104,7 @@
0x03, /* message-name length */
0x66,
0x6F,
- 0x6F /* "foo" */,
+ 0x6F, /* "foo" */
];
i_prot.transport.set_readable_bytes(&source_bytes);
diff --git a/lib/rs/src/protocol/mod.rs b/lib/rs/src/protocol/mod.rs
index f9c1f72..e11a104 100644
--- a/lib/rs/src/protocol/mod.rs
+++ b/lib/rs/src/protocol/mod.rs
@@ -577,14 +577,18 @@
/// ```
pub trait TOutputProtocolFactory {
/// Create a `TOutputProtocol` that writes bytes to `transport`.
- fn create(&self, transport: Box<dyn TWriteTransport + Send>) -> Box<dyn TOutputProtocol + Send>;
+ fn create(&self, transport: Box<dyn TWriteTransport + Send>)
+ -> Box<dyn TOutputProtocol + Send>;
}
impl<T> TOutputProtocolFactory for Box<T>
where
T: TOutputProtocolFactory + ?Sized,
{
- fn create(&self, transport: Box<dyn TWriteTransport + Send>) -> Box<dyn TOutputProtocol + Send> {
+ fn create(
+ &self,
+ transport: Box<dyn TWriteTransport + Send>,
+ ) -> Box<dyn TOutputProtocol + Send> {
(**self).create(transport)
}
}
@@ -679,10 +683,7 @@
/// Create a `TListIdentifier` for a list with `size` elements of type
/// `element_type`.
pub fn new(element_type: TType, size: i32) -> TListIdentifier {
- TListIdentifier {
- element_type,
- size,
- }
+ TListIdentifier { element_type, size }
}
}
@@ -699,10 +700,7 @@
/// Create a `TSetIdentifier` for a set with `size` elements of type
/// `element_type`.
pub fn new(element_type: TType, size: i32) -> TSetIdentifier {
- TSetIdentifier {
- element_type,
- size,
- }
+ TSetIdentifier { element_type, size }
}
}
@@ -878,7 +876,10 @@
/// `actual`.
///
/// Return `()` if `actual == expected`, `Err` otherwise.
-pub fn verify_expected_message_type(expected: TMessageType, actual: TMessageType) -> crate::Result<()> {
+pub fn verify_expected_message_type(
+ expected: TMessageType,
+ actual: TMessageType,
+) -> crate::Result<()> {
if expected == actual {
Ok(())
} else {
diff --git a/lib/rs/src/protocol/multiplexed.rs b/lib/rs/src/protocol/multiplexed.rs
index 83498fb..697b7e6 100644
--- a/lib/rs/src/protocol/multiplexed.rs
+++ b/lib/rs/src/protocol/multiplexed.rs
@@ -191,7 +191,9 @@
#[cfg(test)]
mod tests {
- use crate::protocol::{TBinaryOutputProtocol, TMessageIdentifier, TMessageType, TOutputProtocol};
+ use crate::protocol::{
+ TBinaryOutputProtocol, TMessageIdentifier, TMessageType, TOutputProtocol,
+ };
use crate::transport::{TBufferChannel, TIoChannel, WriteHalf};
use super::*;