comment formating

This commit is contained in:
Kristoffer Ström 2016-10-06 12:07:09 +02:00 committed by arkpar
parent 7a176094d5
commit 91b7780eb5
1 changed files with 5 additions and 8 deletions

View File

@ -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)
}); });