-
-
Save gfreezy/25b03b2cc87f49ce4a49f62d299ffa07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl ConnectionPool { | |
pub fn get_client<'a>(&'a self, addr: &str) -> Option<&'a rpc::Client> { | |
if let Some(&Ok(ref c)) = self.conns.get(addr) { | |
return Some(c); | |
} | |
let c = rpc::Client::new(addr); | |
self.conns.insert(addr.to_string(), c); | |
if let Some(&Ok(ref c)) = self.conns.get(addr) { | |
return Some(c); | |
} | |
None | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment