usetokio_core :: reactor :: {Core,Handle}; usefutures :: future :: Future; usefutures :: future; structClient {handle:Handle,data:usize,} implClient {fnupdate_data(&mutself){//产生新的任务以更新数据本身。 handle.spawn(future :: ok(())。and_then(| x | {self.data + = 1; // errorherefuture :: ok(())}));}} fnmain(){letmutruntime = Core :: new()。unwrap(); letmutclient = Client {handle:runtime.handle(),data:0,}; lettask = future :: ok :: <(),()>(())。and_then(| _ | {//在某些条件下(省略),我们更新dataclient.update_data();将来:: ok :: <(),()>(())}); runtime.run(task).unwrap();}