let latch = self.clone();
// this step ,while LeaderLatch has field zk,zookeeper has ref self
let subscription = self.zk.add_listener(move |x| handle_state_change(&latch, x));
leader.rs fn stop
self.set_path(None)?;//if set_path failed, never remove_listener,so the Arc<ZooKeeper> never drop
......
self.zk.remove_listener(sub);
leader.rs fn start
let latch = self.clone();
// this step ,while LeaderLatch has field zk,zookeeper has ref self let subscription = self.zk.add_listener(move |x| handle_state_change(&latch, x));
leader.rs fn stop