Skip to content

Commit ced4cda

Browse files
committed
refactor
1 parent 3f4b1fb commit ced4cda

File tree

4 files changed

+246
-238
lines changed

4 files changed

+246
-238
lines changed

.github/workflows/ci_check.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ jobs:
2121
runs-on: ${{ matrix.os }}
2222
strategy:
2323
matrix:
24-
os: [ ubuntu-latest, windows-latest, macos-latest ]
24+
os: [ubuntu-latest, windows-latest, macos-latest]
2525
steps:
2626
- uses: actions/checkout@v4
2727
- name: Setup Rust Toolchain
2828
run: |
2929
rustup toolchain install nightly
3030
rustup +nightly component add clippy
31-
- name: Check clippy
31+
- name: Check clippy default
3232
run: |
33-
cargo +nightly clippy --all-features --all-targets -- -Dwarnings
33+
cargo +nightly clippy --all-targets -- -Dwarnings
34+
- name: Check clippy cyper
35+
run: |
36+
cargo +nightly clippy --all-targets --no-default-features --features cyper -- -Dwarnings
3437
- name: Check Docs
3538
run: |
36-
cargo +nightly doc --workspace --all-features --no-deps
39+
cargo +nightly doc --workspace --no-deps

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<C, R, E> QbitBuilder<C, R, E> {
5050
/// Sets the HTTP client for the `Qbit` instance.
5151
///
5252
/// - When `reqwest` feature is enabled (by default), this method accepts a
53-
/// `reqwest::Client`.
53+
/// `reqwest::Client`.
5454
/// - When `cyper` feature is enabled, this method accepts a
5555
/// `cyper::Client`.
5656
pub fn client(self, client: Client) -> QbitBuilder<C, Client, E> {

src/client.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#![allow(unused_imports)]
22

3+
use crate::Result;
4+
35
cfg_if::cfg_if! {
46
if #[cfg(all(feature = "reqwest", feature = "cyper"))] {
57
compile_error!("The 'reqwest' and 'cyper' features cannot be enabled at the same time. To use `cyper`, disable default feature first.");
68
} else if #[cfg(feature = "reqwest")] {
7-
pub(crate) use reqwest::{Client, Error, Method, Response, StatusCode, Url, get, header, multipart};
9+
pub(crate) use reqwest::{Client, Error, Method, Response, StatusCode, Url, RequestBuilder, get, header, multipart};
810
} else if #[cfg(feature = "cyper")] {
9-
pub(crate) use cyper::{Client, Response, Error, multipart};
11+
pub(crate) use cyper::{Client, Response, Error, RequestBuilder, multipart};
1012
pub(crate) use url::Url;
1113
pub(crate) use http::{Method, StatusCode, header};
1214
pub(crate) use cyper_ext::*;
@@ -17,17 +19,16 @@ cfg_if::cfg_if! {
1719

1820
pub(crate) trait CheckError: Sized {
1921
type Ok;
20-
type Error;
21-
fn check(self) -> Result<Self::Ok, Self::Error>;
22+
23+
fn check(self) -> Result<Self::Ok>;
2224
}
2325

2426
#[cfg(feature = "reqwest")]
2527
impl CheckError for reqwest::RequestBuilder {
26-
type Error = reqwest::Error;
2728
type Ok = reqwest::RequestBuilder;
2829

2930
#[inline(always)]
30-
fn check(self) -> Result<Self, Self::Error> {
31+
fn check(self) -> Result<Self> {
3132
Ok(self)
3233
}
3334
}
@@ -56,12 +57,11 @@ mod cyper_ext {
5657
}
5758

5859
impl<T> CheckError for cyper::Result<T> {
59-
type Error = cyper::Error;
6060
type Ok = T;
6161

6262
#[inline(always)]
63-
fn check(self) -> Result<T, Self::Error> {
64-
self
63+
fn check(self) -> Result<T> {
64+
Ok(self?)
6565
}
6666
}
6767
}

0 commit comments

Comments
 (0)