Skip to content

Commit b5268f1

Browse files
authored
Resolve Clippy Warnings (#42)
1 parent 36067a6 commit b5268f1

File tree

13 files changed

+27
-34
lines changed

13 files changed

+27
-34
lines changed

examples/terra-contract/src/contract.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ fn query_fetch_price(deps: Deps) -> StdResult<FetchPriceResponse> {
9797
// for recommendations.
9898
let current_price = price_feed
9999
.get_current_price()
100-
.ok_or(StdError::not_found("Current price is not available"))?;
100+
.ok_or_else(|| StdError::not_found("Current price is not available"))?;
101101

102102
// Get an exponentially-weighted moving average price and confidence interval.
103103
// The same notes about availability apply to this price.
104104
let ema_price = price_feed
105105
.get_ema_price()
106-
.ok_or(StdError::not_found("EMA price is not available"))?;
106+
.ok_or_else(|| StdError::not_found("EMA price is not available"))?;
107107

108-
return Ok(FetchPriceResponse {
108+
Ok(FetchPriceResponse {
109109
current_price,
110110
ema_price,
111-
});
111+
})
112112
}

pyth-sdk-solana/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-sdk-solana"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
authors = ["Pyth Data Foundation"]
55
edition = "2018"
66
license = "Apache-2.0"
@@ -19,7 +19,7 @@ num-derive = "0.3"
1919
num-traits = "0.2"
2020
thiserror = "1.0"
2121
serde = { version = "1.0.136", features = ["derive"] }
22-
pyth-sdk = { path = "../pyth-sdk", version = "0.3.0" }
22+
pyth-sdk = { path = "../pyth-sdk", version = "0.3.1" }
2323

2424
[dev-dependencies]
2525
solana-client = "1.8.1"

pyth-sdk-solana/examples/eth_price.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() {
5858
}
5959
}
6060

61-
println!("");
61+
println!();
6262

6363
thread::sleep(time::Duration::from_secs(1));
6464
}

pyth-sdk-solana/examples/get_accounts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn main() {
5959
// print key and reference data for this Product
6060
println!("product_account .. {:?}", prod_pkey);
6161
for (key, val) in prod_acct.iter() {
62-
if key.len() > 0 {
62+
if !key.is_empty() {
6363
println!(" {:.<16} {}", key, val);
6464
}
6565
}

pyth-sdk-solana/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn load_price_feed_from_account_info(
3535
.map_err(|_| PythError::InvalidAccountData)?;
3636
let price_account = load_price_account(*data)?;
3737

38-
Ok(price_account.to_price_feed(&price_account_info.key))
38+
Ok(price_account.to_price_feed(price_account_info.key))
3939
}
4040

4141
/// Loads Pyth Price Feed from Account when using Solana Client.

pyth-sdk-solana/src/state.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ fn load<T: Pod>(data: &[u8]) -> Result<&T, PodCastError> {
405405

406406
/// Get a `Mapping` account from the raw byte value of a Solana account.
407407
pub fn load_mapping_account(data: &[u8]) -> Result<&MappingAccount, PythError> {
408-
let pyth_mapping = load::<MappingAccount>(&data).map_err(|_| PythError::InvalidAccountData)?;
408+
let pyth_mapping = load::<MappingAccount>(data).map_err(|_| PythError::InvalidAccountData)?;
409409

410410
if pyth_mapping.magic != MAGIC {
411411
return Err(PythError::InvalidAccountData);
@@ -417,12 +417,12 @@ pub fn load_mapping_account(data: &[u8]) -> Result<&MappingAccount, PythError> {
417417
return Err(PythError::WrongAccountType);
418418
}
419419

420-
return Ok(pyth_mapping);
420+
Ok(pyth_mapping)
421421
}
422422

423423
/// Get a `Product` account from the raw byte value of a Solana account.
424424
pub fn load_product_account(data: &[u8]) -> Result<&ProductAccount, PythError> {
425-
let pyth_product = load::<ProductAccount>(&data).map_err(|_| PythError::InvalidAccountData)?;
425+
let pyth_product = load::<ProductAccount>(data).map_err(|_| PythError::InvalidAccountData)?;
426426

427427
if pyth_product.magic != MAGIC {
428428
return Err(PythError::InvalidAccountData);
@@ -434,12 +434,12 @@ pub fn load_product_account(data: &[u8]) -> Result<&ProductAccount, PythError> {
434434
return Err(PythError::WrongAccountType);
435435
}
436436

437-
return Ok(pyth_product);
437+
Ok(pyth_product)
438438
}
439439

440440
/// Get a `Price` account from the raw byte value of a Solana account.
441441
pub fn load_price_account(data: &[u8]) -> Result<&PriceAccount, PythError> {
442-
let pyth_price = load::<PriceAccount>(&data).map_err(|_| PythError::InvalidAccountData)?;
442+
let pyth_price = load::<PriceAccount>(data).map_err(|_| PythError::InvalidAccountData)?;
443443

444444
if pyth_price.magic != MAGIC {
445445
return Err(PythError::InvalidAccountData);
@@ -451,7 +451,7 @@ pub fn load_price_account(data: &[u8]) -> Result<&PriceAccount, PythError> {
451451
return Err(PythError::WrongAccountType);
452452
}
453453

454-
return Ok(pyth_price);
454+
Ok(pyth_price)
455455
}
456456

457457
pub struct AttributeIter<'a> {
@@ -468,7 +468,7 @@ impl<'a> Iterator for AttributeIter<'a> {
468468
let (key, data) = get_attr_str(self.attrs);
469469
let (val, data) = get_attr_str(data);
470470
self.attrs = data;
471-
return Some((key, val));
471+
Some((key, val))
472472
}
473473
}
474474

pyth-sdk-solana/test-contract/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[package]
22
name = "test-contract"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2018"
55

66
[features]
77
test-bpf = []
88
no-entrypoint = []
99

1010
[dependencies]
11-
pyth-sdk-solana = { path = "../", version = "0.3.0" }
11+
pyth-sdk-solana = { path = "../", version = "0.3.1" }
1212
solana-program = "1.8.1"
1313
bytemuck = "1.7.2"
1414
borsh = "0.9"

pyth-sdk-solana/test-contract/tests/instruction_count.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ mod common;
77
use common::test_instr_exec_ok;
88

99
fn pc(price: i64, conf: u64, expo: i32) -> Price {
10-
Price {
11-
price: price,
12-
conf: conf,
13-
expo: expo,
14-
}
10+
Price { price, conf, expo }
1511
}
1612

1713
#[tokio::test]

pyth-sdk-terra/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ readme = "README.md"
1414
cosmwasm-std = { version = "0.16.0" }
1515
cosmwasm-storage = { version = "0.16.0" }
1616
serde = { version = "1.0.136", features = ["derive"] }
17-
pyth-sdk = { path = "../pyth-sdk", version = "0.3.0" }
17+
pyth-sdk = { path = "../pyth-sdk", version = "0.3.1" }
1818
schemars = "0.8.1"
1919

2020
[dev-dependencies]

pyth-sdk-terra/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pyth_contract_addr: string = "terra1hdc8q4ejy82kd9w7wj389dlul9z5zz9a36jflh";
2525
price_feed_id: string = "0xf9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b";
2626

2727
let price_feed: PriceFeed = query_price_feed(deps.querier, pyth_contract_addr, price_feed_id)?.price_feed;
28-
let current_price: Price = price_feed.get_current_price().ok_or(StdError::not_found("price is not currently available"))?;
28+
let current_price: Price = price_feed.get_current_price().ok_or_else(|| StdError::not_found("price is not currently available"))?;
2929
println!("current BTC/USD price: ({} +- {}) x 10^{}", current_price.price, current_price.conf, current_price.expo);
3030
```
3131

0 commit comments

Comments
 (0)