comment formating
This commit is contained in:
parent
7a176094d5
commit
91b7780eb5
@ -158,17 +158,14 @@ impl Rpc {
|
|||||||
Err(e) => return done(Ok(Err(e))).boxed(),
|
Err(e) => return done(Ok(Err(e))).boxed(),
|
||||||
Ok(code) => {
|
Ok(code) => {
|
||||||
let url = String::from(url);
|
let url = String::from(url);
|
||||||
// The ws::connect takes a FnMut closure,
|
// The ws::connect takes a FnMut closure, which means c cannot be
|
||||||
// which means c cannot be moved into it,
|
// moved into it, since it's consumed on complete.
|
||||||
// since it's consumed on complete.
|
// Therefore we wrap it in an option and pick it out once.
|
||||||
// Therefore we wrap it in an option
|
|
||||||
// and pick it out once.
|
|
||||||
let mut once = Some(c);
|
let mut once = Some(c);
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let conn = ws::connect(url, |out| {
|
let conn = ws::connect(url, |out| {
|
||||||
// this will panic if the closure
|
// this will panic if the closure is called twice,
|
||||||
// is called twice, which it should never
|
// which it should never be.
|
||||||
// be.
|
|
||||||
let c = once.take().expect("connection closure called only once");
|
let c = once.take().expect("connection closure called only once");
|
||||||
RpcHandler::new(out, code.clone(), c)
|
RpcHandler::new(out, code.clone(), c)
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user