Skip to content

Commit 2b701ac

Browse files
Sh3Rm4nJohnTitor
authored andcommitted
Fix list_generic_family example
* Increase capacity * Break the loop once buffer is empty
1 parent a5aa5c0 commit 2b701ac

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/list_generic_family.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ fn main() {
2828

2929
socket.send(&txbuf, 0).unwrap();
3030

31-
let mut rxbuf = Vec::with_capacity(4096);
31+
let mut rxbuf = Vec::with_capacity(8192);
3232
let mut offset = 0;
33-
33+
let mut size = 0;
3434
'outer: loop {
35-
let size = socket.recv(&mut rxbuf, 0).unwrap();
35+
size += socket.recv(&mut rxbuf, 0).unwrap();
3636

3737
loop {
3838
let buf = &rxbuf[offset..];
@@ -56,7 +56,6 @@ fn main() {
5656

5757
offset += msg.header.length as usize;
5858
if offset == size || msg.header.length == 0 {
59-
offset = 0;
6059
break;
6160
}
6261
}

0 commit comments

Comments
 (0)