Skip to content

Commit 5bab07d

Browse files
Andronik Ordianascjones
authored andcommitted
Fix other clippy warning (paritytech#395)
* fix missing docs attribute * use shorthand syntax * fix some other clippy warnings
1 parent d86d7a1 commit 5bab07d

30 files changed

+97
-97
lines changed

core/src/delegates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<T, M> IoDelegate<T, M> where
7979
/// Creates new `IoDelegate`
8080
pub fn new(delegate: Arc<T>) -> Self {
8181
IoDelegate {
82-
delegate: delegate,
82+
delegate,
8383
methods: HashMap::new(),
8484
}
8585
}

core/src/io.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ impl Default for Compatibility {
6464
}
6565

6666
impl Compatibility {
67-
fn is_version_valid(&self, version: Option<Version>) -> bool {
68-
match (*self, version) {
67+
fn is_version_valid(self, version: Option<Version>) -> bool {
68+
match (self, version) {
6969
(Compatibility::V1, None) |
7070
(Compatibility::V2, Some(Version::V2)) |
7171
(Compatibility::Both, _) => true,
7272
_ => false,
7373
}
7474
}
7575

76-
fn default_version(&self) -> Option<Version> {
77-
match *self {
76+
fn default_version(self) -> Option<Version> {
77+
match self {
7878
Compatibility::V1 => None,
7979
Compatibility::V2 | Compatibility::Both => Some(Version::V2),
8080
}
@@ -101,7 +101,7 @@ impl<T: Metadata> MetaIoHandler<T> {
101101
/// Creates new `MetaIoHandler` compatible with specified protocol version.
102102
pub fn with_compatibility(compatibility: Compatibility) -> Self {
103103
MetaIoHandler {
104-
compatibility: compatibility,
104+
compatibility,
105105
middleware: Default::default(),
106106
methods: Default::default(),
107107
}
@@ -113,8 +113,8 @@ impl<T: Metadata, S: Middleware<T>> MetaIoHandler<T, S> {
113113
/// Creates new `MetaIoHandler`
114114
pub fn new(compatibility: Compatibility, middleware: S) -> Self {
115115
MetaIoHandler {
116-
compatibility: compatibility,
117-
middleware: middleware,
116+
compatibility,
117+
middleware,
118118
methods: Default::default(),
119119
}
120120
}
@@ -123,7 +123,7 @@ impl<T: Metadata, S: Middleware<T>> MetaIoHandler<T, S> {
123123
pub fn with_middleware(middleware: S) -> Self {
124124
MetaIoHandler {
125125
compatibility: Default::default(),
126-
middleware: middleware,
126+
middleware,
127127
methods: Default::default(),
128128
}
129129
}

core/src/types/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Error {
9494
pub fn new(code: ErrorCode) -> Self {
9595
Error {
9696
message: code.description(),
97-
code: code,
97+
code,
9898
data: None
9999
}
100100
}

core/src/types/response.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ impl Output {
4141
pub fn from(result: CoreResult<Value>, id: Id, jsonrpc: Option<Version>) -> Self {
4242
match result {
4343
Ok(result) => Output::Success(Success {
44-
id: id,
45-
jsonrpc: jsonrpc,
46-
result: result,
44+
id,
45+
jsonrpc,
46+
result,
4747
}),
4848
Err(error) => Output::Failure(Failure {
49-
id: id,
50-
jsonrpc: jsonrpc,
51-
error: error,
49+
id,
50+
jsonrpc,
51+
error,
5252
}),
5353
}
5454
}
5555

5656
/// Creates new failure output indicating malformed request.
5757
pub fn invalid_request(id: Id, jsonrpc: Option<Version>) -> Self {
5858
Output::Failure(Failure {
59-
id: id,
60-
jsonrpc: jsonrpc,
59+
id,
60+
jsonrpc,
6161
error: Error::new(ErrorCode::InvalidRequest),
6262
})
6363
}
@@ -104,8 +104,8 @@ impl Response {
104104
pub fn from(error: Error, jsonrpc: Option<Version>) -> Self {
105105
Failure {
106106
id: Id::Null,
107-
jsonrpc: jsonrpc,
108-
error: error,
107+
jsonrpc,
108+
error,
109109
}.into()
110110
}
111111
}

core/src/types/version.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub enum Version {
1414
impl Serialize for Version {
1515
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1616
where S: Serializer {
17-
match self {
18-
&Version::V2 => serializer.serialize_str("2.0")
17+
match *self {
18+
Version::V2 => serializer.serialize_str("2.0")
1919
}
2020
}
2121
}

derive/src/rpc_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl RpcMethodAttribute {
7373
.map_or(Vec::new(), |ml| get_aliases(ml));
7474
Ok(RpcMethodAttribute {
7575
attr: attr.clone(),
76-
name: name,
76+
name,
7777
aliases,
7878
kind
7979
})

derive/src/to_delegate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl RpcMethod {
273273
let total_args_num = param_types.len();
274274
let required_args_num = total_args_num - trailing_args_num;
275275

276-
let switch_branches = (0..trailing_args_num+1)
276+
let switch_branches = (0..=trailing_args_num)
277277
.map(|passed_trailing_args_num| {
278278
let passed_args_num = required_args_num + passed_trailing_args_num;
279279
let passed_param_types = &param_types[..passed_args_num];

http/src/handler.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<M: Metadata, S: Middleware<M>> Future for RpcHandler<M, S> {
260260
},
261261
RpcHandlerState::WaitingForResponse(mut waiting) => {
262262
match waiting.poll() {
263-
Ok(Async::Ready(response)) => RpcPollState::Ready(RpcHandlerState::Writing(response.into())),
263+
Ok(Async::Ready(response)) => RpcPollState::Ready(RpcHandlerState::Writing(response)),
264264
Ok(Async::NotReady) => RpcPollState::NotReady(RpcHandlerState::WaitingForResponse(waiting)),
265265
Err(e) => RpcPollState::Ready(RpcHandlerState::Writing(
266266
Response::internal_error(format!("{:?}", e))
@@ -275,7 +275,7 @@ impl<M: Metadata, S: Middleware<M>> Future for RpcHandler<M, S> {
275275
None => Response::ok(String::new()),
276276
// Add new line to have nice output when using CLI clients (curl)
277277
Some(result) => Response::ok(format!("{}\n", result)),
278-
}.into()))
278+
}))
279279
},
280280
Ok(Async::NotReady) => RpcPollState::NotReady(RpcHandlerState::Waiting(waiting)),
281281
Err(e) => RpcPollState::Ready(RpcHandlerState::Writing(
@@ -404,7 +404,7 @@ impl<M: Metadata, S: Middleware<M>> RpcHandler<M, S> {
404404
id: Id::Num(1),
405405
}));
406406

407-
return Ok(RpcPollState::Ready(RpcHandlerState::WaitingForResponse(
407+
Ok(RpcPollState::Ready(RpcHandlerState::WaitingForResponse(
408408
future::Either::B(self.jsonrpc_handler.handler.handle_rpc_request(call, metadata))
409409
.map(|res| match res {
410410
Some(core::Response::Single(Output::Success(Success { result, .. }))) => {
@@ -421,7 +421,7 @@ impl<M: Metadata, S: Middleware<M>> RpcHandler<M, S> {
421421
},
422422
e => Response::internal_error(format!("Invalid response for health request: {:?}", e)),
423423
})
424-
)));
424+
)))
425425
}
426426

427427
fn process_rest(
@@ -452,12 +452,12 @@ impl<M: Metadata, S: Middleware<M>> RpcHandler<M, S> {
452452
id: Id::Num(1),
453453
}));
454454

455-
return Ok(RpcPollState::Ready(RpcHandlerState::Waiting(
455+
Ok(RpcPollState::Ready(RpcHandlerState::Waiting(
456456
future::Either::B(self.jsonrpc_handler.handler.handle_rpc_request(call, metadata))
457457
.map(|res| res.map(|x| serde_json::to_string(&x)
458458
.expect("Serialization of response is infallible;qed")
459459
))
460-
)));
460+
)))
461461
}
462462

463463
fn process_body(

http/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<M: jsonrpc::Metadata, S: jsonrpc::Middleware<M>> ServerBuilder<M, S> {
321321

322322
/// Configure the CORS `AccessControlAllowHeaders` header which are allowed.
323323
pub fn cors_allow_headers(mut self, allowed_headers: cors::AccessControlAllowHeaders) -> Self {
324-
self.allowed_headers = allowed_headers.into();
324+
self.allowed_headers = allowed_headers;
325325
self
326326
}
327327

@@ -583,8 +583,8 @@ impl Server {
583583

584584
impl Drop for Server {
585585
fn drop(&mut self) {
586-
self.executor.take().map(|executors| {
586+
if let Some(executors) = self.executor.take() {
587587
for executor in executors { executor.close(); }
588-
});
588+
};
589589
}
590590
}

http/src/response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Response {
4242
Response {
4343
code: StatusCode::SERVICE_UNAVAILABLE,
4444
content_type: HeaderValue::from_static("application/json; charset=utf-8"),
45-
content: format!("{}", msg.into()),
45+
content: msg.into(),
4646
}
4747
}
4848

0 commit comments

Comments
 (0)