Skip to content

Commit a4fcd95

Browse files
committed
Pass clippy.
1 parent 515be2e commit a4fcd95

File tree

30 files changed

+164
-78
lines changed

30 files changed

+164
-78
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
with:
7070
toolchain: stable
7171
override: true
72-
components: rustfmt
72+
components: clippy
7373

7474
- name: Cargo fmt
7575
uses: actions-rs/cargo@v1
@@ -85,6 +85,13 @@ jobs:
8585
command: build
8686
args: --release
8787

88+
- name: Cargo clippy
89+
uses: actions-rs/cargo@v1
90+
with:
91+
toolchain: stable
92+
command: clippy
93+
args: --release
94+
8895
- name: Cargo test
8996
uses: actions-rs/cargo@v1
9097
with:

examples/http-client/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use phper::{
1111
use reqwest::blocking::{Client, ClientBuilder, RequestBuilder};
1212
use std::time::Duration;
1313

14-
const HTTP_CLIENT_BUILDER_CLASS_NAME: &'static str = "HttpClient\\HttpClientBuilder";
15-
const HTTP_CLIENT_CLASS_NAME: &'static str = "HttpClient\\HttpClient";
14+
const HTTP_CLIENT_BUILDER_CLASS_NAME: &str = "HttpClient\\HttpClientBuilder";
15+
const HTTP_CLIENT_CLASS_NAME: &str = "HttpClient\\HttpClient";
1616

1717
pub fn make_client_builder_class() -> DynamicClass<ClientBuilder> {
1818
let mut class = DynamicClass::new_with_default(HTTP_CLIENT_BUILDER_CLASS_NAME);

examples/http-client/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use phper::classes::{ClassEntry, DynamicClass};
22

3-
const EXCEPTION_CLASS_NAME: &'static str = "HttpClient\\HttpClientException";
3+
const EXCEPTION_CLASS_NAME: &str = "HttpClient\\HttpClientException";
44

55
#[derive(Debug, thiserror::Error, phper::Throwable)]
66
#[throwable_class(EXCEPTION_CLASS_NAME)]

examples/http-client/src/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use phper::{
55
};
66
use reqwest::blocking::{RequestBuilder, Response};
77

8-
pub const REQUEST_BUILDER_CLASS_NAME: &'static str = "HttpClient\\RequestBuilder";
8+
pub const REQUEST_BUILDER_CLASS_NAME: &str = "HttpClient\\RequestBuilder";
99

1010
pub fn make_request_builder_class() -> DynamicClass<Option<RequestBuilder>> {
1111
let mut class = DynamicClass::new_with_default(REQUEST_BUILDER_CLASS_NAME);

examples/http-client/src/response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use phper::{
66
};
77
use reqwest::blocking::Response;
88

9-
pub const RESPONSE_CLASS_NAME: &'static str = "HttpClient\\Response";
9+
pub const RESPONSE_CLASS_NAME: &str = "HttpClient\\Response";
1010

1111
pub fn make_response_class() -> DynamicClass<Option<Response>> {
1212
let mut class = DynamicClass::new_with_default(RESPONSE_CLASS_NAME);

examples/http-client/src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::mem::replace;
1+
use std::mem::{take, replace};
22

33
pub fn replace_and_set<T: Default>(t: &mut T, f: impl FnOnce(T) -> T) {
4-
let x = f(replace(t, Default::default()));
4+
let x = f(take(t));
55
let _ = replace(t, x);
66
}
77

88
pub fn replace_and_get<T: Default, R>(t: &mut T, f: impl FnOnce(T) -> R) -> R {
9-
f(replace(t, Default::default()))
9+
f(take(t))
1010
}

examples/http-server/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use hyper::header::{InvalidHeaderName, InvalidHeaderValue};
22
use phper::classes::{ClassEntry, DynamicClass};
33
use std::net::AddrParseError;
44

5-
const EXCEPTION_CLASS_NAME: &'static str = "HttpServer\\HttpServerException";
5+
const EXCEPTION_CLASS_NAME: &str = "HttpServer\\HttpServerException";
66

77
#[derive(Debug, thiserror::Error, phper::Throwable)]
88
#[throwable_class(EXCEPTION_CLASS_NAME)]

examples/http-server/src/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use phper::classes::{DynamicClass, Visibility};
22

3-
pub const HTTP_REQUEST_CLASS_NAME: &'static str = "HttpServer\\HttpRequest";
3+
pub const HTTP_REQUEST_CLASS_NAME: &str = "HttpServer\\HttpRequest";
44

55
pub fn make_request_class() -> DynamicClass<()> {
66
let mut class = DynamicClass::new(HTTP_REQUEST_CLASS_NAME);

examples/http-server/src/response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use phper::{
55
functions::Argument,
66
};
77

8-
pub const HTTP_RESPONSE_CLASS_NAME: &'static str = "HttpServer\\HttpResponse";
8+
pub const HTTP_RESPONSE_CLASS_NAME: &str = "HttpServer\\HttpResponse";
99

1010
pub fn make_response_class() -> DynamicClass<Response<Body>> {
1111
let mut class = DynamicClass::new_with_default(HTTP_RESPONSE_CLASS_NAME);

examples/http-server/src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use phper::{
1616
use std::{convert::Infallible, mem::replace, net::SocketAddr, sync::Arc};
1717
use tokio::{runtime::Handle, sync::Mutex};
1818

19-
const HTTP_SERVER_CLASS_NAME: &'static str = "HttpServer\\HttpServer";
19+
const HTTP_SERVER_CLASS_NAME: &str = "HttpServer\\HttpServer";
2020

2121
pub fn make_server_class() -> DynamicClass<Option<Builder<AddrIncoming>>> {
2222
let mut class = DynamicClass::new_with_default(HTTP_SERVER_CLASS_NAME);
@@ -89,7 +89,7 @@ pub fn make_server_class() -> DynamicClass<Option<Builder<AddrIncoming>>> {
8989
StatusCode::INTERNAL_SERVER_ERROR;
9090
*response.as_mut_state().body_mut() = ex.to_string().into();
9191
}
92-
Err(e) => Err(e)?,
92+
Err(e) => return Err(e.into()),
9393
_ => {}
9494
}
9595

0 commit comments

Comments
 (0)