Created
April 14, 2016 14:59
-
-
Save BonsaiDen/89d14290fa6b8d358f620141c130bb1c to your computer and use it in GitHub Desktop.
rustfmt results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before --------------------------------------------------------------------- | |
self.delay_until_good_mode = cmp::min( | |
self.delay_until_good_mode, | |
MAX_GOOD_MODE_TIME_DELAY | |
); | |
// After ---------------------------------------------------------------------- | |
self.delay_until_good_mode = cmp::min(self.delay_until_good_mode, | |
MAX_GOOD_MODE_TIME_DELAY); | |
// More Alignment Issues | |
write_messages(&mut self.i_queue, | |
packet, | |
(available as f32 / 100.0 * self.config.message_quota_instant) as usize, | |
&mut written); | |
write_messages(&mut self.r_queue, | |
packet, | |
(available as f32 / 100.0 * self.config.message_quota_reliable) as usize, | |
&mut written); | |
write_messages(&mut self.o_queue, | |
packet, | |
(available as f32 / 100.0 * self.config.message_quota_ordered) as usize, | |
&mut written); | |
Message { | |
data: packet[index + MESSAGE_HEADER_BYTES..cmp::min(index + MESSAGE_HEADER_BYTES + | |
size as usize, | |
available)] | |
.to_vec(), | |
} | |
fn connection_packet_decompress(&mut self, | |
_: &mut T, | |
_: &mut Connection, | |
data: &[u8]) | |
-> Vec<u8> { | |
data.to_vec() | |
} | |
fn write_messages(queue: &mut VecDeque<Message>, | |
packet: &mut Vec<u8>, | |
available: usize, | |
written: &mut usize) { | |
let mut used = 0; | |
while write_message(queue, packet, available, &mut used) {} | |
*written += used; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before --------------------------------------------------------------------- | |
q.receive_packet(&[ | |
2, 0, 0, 1, 53, // Expected #1 | |
2, 1, 0, 1, 54, // Expected #2 | |
2, 1, 0, 1, 55, | |
2, 1, 0, 1, 56, | |
2, 2, 0, 1, 57, // Expected #3 | |
2, 2, 0, 1, 58, | |
2, 3, 0, 1, 59 // Expected #4 | |
]); | |
// After ---------------------------------------------------------------------- | |
q.receive_packet(&[2, 0, 0, 1, 53 /* Expected #1 */, 2, 1, 0, 1, | |
54 /* Expected #2 */, 2, 1, 0, 1, 55, 2, 1, 0, 1, 56, 2, 2, 0, 1, | |
57 /* Expected #3 */, 2, 2, 0, 1, 58, 2, 3, 0, 1, | |
59 /* Expected #4 */]); | |
// Before --------------------------------------------------------------------- | |
assert_eq!(buffer, [ | |
// Hello World | |
0, 0, 0, 11, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, | |
// Hello World | |
0, 0, 0, 11, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, | |
// Foo | |
1, 0, 0, 3, 70, 111, 111, | |
// Bar | |
2, 0, 0, 3, 66, 97, 114, | |
// Hello World | |
0, 0, 0, 11, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100 | |
].to_vec()); | |
// After ---------------------------------------------------------------------- | |
assert_eq!(buffer, | |
[// Hello World | |
0, | |
0, | |
0, | |
11, | |
72, | |
101, | |
108, | |
108, | |
111, | |
32, | |
87, | |
111, | |
114, | |
108, | |
100, | |
// Hello World | |
0, | |
0, | |
0, | |
11, | |
72, | |
101, | |
108, | |
108, | |
111, | |
32, | |
87, | |
111, | |
114, | |
108, | |
100, | |
// Foo | |
1, | |
0, | |
0, | |
3, | |
70, | |
111, | |
111, | |
// Bar | |
2, | |
0, | |
0, | |
3, | |
66, | |
97, | |
114, | |
// Hello World | |
0, | |
0, | |
0, | |
11, | |
72, | |
101, | |
108, | |
108, | |
111, | |
32, | |
87, | |
111, | |
114, | |
108, | |
100] | |
.to_vec()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment