Skip to content

Commit 4f40ea5

Browse files
refactor(bigchaindb): clippy
1 parent 7f4a1a7 commit 4f40ea5

File tree

5 files changed

+29
-21
lines changed

5 files changed

+29
-21
lines changed

src/connection.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ use crate::{
99
transport::Transport,
1010
};
1111

12-
const BLOCKS: &'static str = "blocks";
13-
const BLOCKS_DETAIL: &'static str = "blocks/%(blockHeight)s";
14-
const OUTPUTS: &'static str = "outputs";
15-
const TRANSACTIONS: &'static str = "transactions";
16-
const TRANSACTIONS_SYNC: &'static str = "transactions?mode=sync";
17-
const TRANSACTIONS_ASYNC: &'static str = "transactions?mode=async";
18-
const TRANSACTIONS_COMMIT: &'static str = "transactions?mode=commit";
19-
const TRANSACTIONS_DETAIL: &'static str = "transactions/{transaction_id}";
20-
const ASSETS: &'static str = "assets";
21-
const METADATA: &'static str = "metadata";
12+
const BLOCKS: &str = "blocks";
13+
const BLOCKS_DETAIL: &str = "blocks/%(blockHeight)s";
14+
const OUTPUTS: &str = "outputs";
15+
const TRANSACTIONS: &str = "transactions";
16+
const TRANSACTIONS_SYNC: &str = "transactions?mode=sync";
17+
const TRANSACTIONS_ASYNC: &str = "transactions?mode=async";
18+
const TRANSACTIONS_COMMIT: &str = "transactions?mode=commit";
19+
const TRANSACTIONS_DETAIL: &str = "transactions/{transaction_id}";
20+
const ASSETS: &str = "assets";
21+
const METADATA: &str = "metadata";
2222

23-
const DEFAULT_NODE: &'static str = "http://localhost:9984/api/v1/";
23+
const DEFAULT_NODE: &str = "http://localhost:9984/api/v1/";
2424
const DEFAULT_TIMEOUT: u64 = 20; // default timeout is 20 seconds
2525

2626
#[derive(Debug, Clone)]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ pub mod json {
99
pub use serde_json::*;
1010
}
1111

12-
use bs58;
12+
1313
use crypto_conditions::{fulfillment::Fulfillment, Ed25519Sha256};
1414
use rand::RngCore;
1515
use serde::{Deserialize, Serialize};
1616
use stable_sort::stable_sorted;
17-
use tweetnacl;
17+
1818

1919
pub fn randombytes(seed: &mut [u8; 32]) {
2020
let mut rng = rand::thread_rng();

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async fn test_post_transaction_commit() {
2222
let metadata = json!({"metadata": "rust"});
2323
let public_key = "6zaQbbRi7RCFhCF35tpVDu2nEfR9fZCqx2MvUa7pKRmX";
2424
let private_key = "CHwxsNPzRXTzCz25KZ9TJcBJ45H25JKkLL4HrX1nBfXT";
25-
let condition = Transaction::make_ed25519_condition(&public_key, true).unwrap();
25+
let condition = Transaction::make_ed25519_condition(public_key, true).unwrap();
2626
let output = Transaction::make_output(condition, String::from("1"));
2727
let transaction = Transaction::make_create_transaction(
2828
Some(assetdata),

src/request.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ pub struct RequestOption<'a> {
4040
pub url_template: Option<UrlTemplateSpec<'a>>,
4141
}
4242

43+
impl<'a> Default for RequestOption<'a> {
44+
fn default() -> Self {
45+
Self::new()
46+
}
47+
}
48+
4349
impl<'a> RequestOption<'a> {
4450
pub fn new() -> Self {
4551
Self {
@@ -186,7 +192,7 @@ pub async fn base_request<T: DeserializeOwned>(
186192
let body = serde_json::to_string(
187193
&request_config
188194
.json_body
189-
.ok_or_else(|| Error::RequestNoBodyProvided)?,
195+
.ok_or(Error::RequestNoBodyProvided)?,
190196
)
191197
.map_err(|_| Error::SerdeError)?;
192198

src/transaction.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ pub struct TransactionTemplate {
102102
pub version: String,
103103
}
104104

105+
impl Default for TransactionTemplate {
106+
fn default() -> Self {
107+
Self::new()
108+
}
109+
}
110+
105111
impl TransactionTemplate {
106112
pub fn new() -> Self {
107113
Self {
@@ -146,11 +152,7 @@ impl Transaction {
146152
outputs: Vec<Output>,
147153
issuers: Vec<String>,
148154
) -> TransactionTemplate {
149-
let asset = if let Some(asset) = asset {
150-
Some(Asset::Definition(CreateAsset { data: asset }))
151-
} else {
152-
None
153-
};
155+
let asset = asset.map(|asset| Asset::Definition(CreateAsset { data: asset }));
154156
let inputs: Vec<InputTemplate> = issuers
155157
.iter()
156158
.map(|issuer| InputTemplate::new(vec![issuer.to_string()], None, None))
@@ -248,7 +250,7 @@ impl Transaction {
248250
.get("transaction_id")
249251
.expect("no transaction_id in json::Value")
250252
.to_string()
251-
.replace("\"", ""); // remove double quotes around the string
253+
.replace('\"', ""); // remove double quotes around the string
252254
let output_index = fulfills
253255
.get("output_index")
254256
.expect("no output_index in json::Value")

0 commit comments

Comments
 (0)