Merge pull request #7357 from paritytech/unwrap-or

Avoid using ok_or with allocated argument
This commit is contained in:
Marek Kotewicz
2017-12-22 06:55:37 -04:00
committed by GitHub
8 changed files with 10 additions and 10 deletions

View File

@@ -58,7 +58,7 @@ impl ValidatorContract {
let client = self.client.read().clone();
Box::new(move |a, d| client.as_ref()
.and_then(Weak::upgrade)
.ok_or("No client!".into())
.ok_or_else(|| "No client!".into())
.and_then(|c| {
match c.as_full_client() {
Some(c) => c.transact_contract(a, d)

View File

@@ -138,7 +138,7 @@ impl ValidatorSet for Multi {
}
*self.block_number.write() = Box::new(move |id| client
.upgrade()
.ok_or("No client!".into())
.ok_or_else(|| "No client!".into())
.and_then(|c| c.block_number(id).ok_or("Unknown block".into())));
}
}

View File

@@ -311,7 +311,7 @@ impl ValidatorSet for ValidatorSafeContract {
let client = self.client.read().clone();
Box::new(move |addr, data| client.as_ref()
.and_then(Weak::upgrade)
.ok_or("No client!".into())
.ok_or_else(|| "No client!".into())
.and_then(|c| {
match c.as_full_client() {
Some(c) => c.call_contract(id, addr, data),