我在HashSet
之外定义loop
,最终会填充它。
类似的东西:
let mut keys = HashSet::new();
loop {
let mss = try!(con.poll()); // taken from kafka-rust
// some code
keys.insert(stuff);
// some code
try!(con.commit_consumed());
}
现在我有明显的reference must be valid for the block suffix following statement
:
note: reference must be valid for the block suffix following statement 1 at 28:34...
--> src/main.rs:28:35
|
28 | let mut keys = HashSet::new();
| ^
note: ...but borrowed value is only valid for the block suffix following statement 0 at 30:35
--> src/main.rs:30:36
|
30 | let mss = try!(con.poll());
| ^
error: aborting due to previous error
这样做的正确方法是什么?