Skip to content

Commit 7b45cbf

Browse files
authored
chore: fix clippy warnings (#102)
1 parent 4c05a47 commit 7b45cbf

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ documentation = "https://docs.rs/mobc/latest/mobc/"
1515
[features]
1616
default = ["tokio", "unstable"]
1717
unstable = []
18+
docs = []
1819

1920
[dependencies]
2021
futures-core = "0.3"
@@ -48,5 +49,5 @@ name = "tide"
4849
required-features = ["async-std"]
4950

5051
[package.metadata.docs.rs]
51-
features = ["unstable"]
52+
features = ["unstable", "docs"]
5253
rustdoc-args = ["--cfg", "feature=\"unstable\""]

src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,7 @@ impl<M: Manager> Pool<M> {
454454
}
455455
}
456456

457-
let create_r = self.open_new_connection(permit).await;
458-
459-
create_r
457+
self.open_new_connection(permit).await
460458
}
461459

462460
async fn open_new_connection(

src/runtime.rs

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A batteries included runtime for applications using mobc.
22
//! Mobc does not implement runtime, it simply exports runtime.
33
4-
pub use runtime::{DefaultExecutor, Runtime, TaskExecutor};
4+
pub use internal::{DefaultExecutor, Runtime, TaskExecutor};
55

66
use std::future::Future;
77
use std::pin::Pin;
@@ -21,30 +21,30 @@ pub trait Executor: Send + Sync + 'static + Clone {
2121
}
2222

2323
#[cfg(all(feature = "tokio", not(feature = "async-std")))]
24-
mod runtime {
24+
mod internal {
2525
use super::*;
2626

27-
/// Wrapper of the Tokio Runtime
27+
/// Wrapper of the Tokio Runtime.
2828
pub struct Runtime {
2929
rt: tokio::runtime::Runtime,
3030
spawner: TaskExecutor,
3131
}
3232

3333
impl Runtime {
34-
/// Creates a new Runtime
34+
/// Creates a new [`Runtime`].
3535
pub fn new() -> Option<Self> {
3636
Some(Runtime {
3737
rt: tokio::runtime::Runtime::new().unwrap(),
3838
spawner: TaskExecutor,
3939
})
4040
}
4141

42-
/// Returns a spawner
42+
/// Returns a spawner.
4343
pub fn handle(&self) -> &TaskExecutor {
4444
&self.spawner
4545
}
4646

47-
/// Run a future to completion on the Tokio runtime. This is the
47+
/// Runs a future to completion on the Tokio runtime. This is the
4848
/// runtime's entry point.
4949
pub fn block_on<F, T>(&mut self, future: F) -> T
5050
where
@@ -53,7 +53,7 @@ mod runtime {
5353
self.rt.block_on(future)
5454
}
5555

56-
/// Spawn a future onto the Tokio runtime.
56+
/// Spawns a future onto the Tokio runtime.
5757
pub fn spawn<F, T>(&self, future: F)
5858
where
5959
F: Future<Output = T> + Send + 'static,
@@ -63,12 +63,12 @@ mod runtime {
6363
}
6464
}
6565

66-
/// Simple handler for spawning task
66+
/// Simple handler for spawning task.
6767
#[derive(Clone)]
6868
pub struct TaskExecutor;
6969

7070
impl TaskExecutor {
71-
/// Spawn a future onto the Tokio runtime.
71+
/// Spawns a future onto the Tokio runtime.
7272
pub fn spawn<F>(&self, future: F)
7373
where
7474
F: Future + Send + 'static,
@@ -96,15 +96,17 @@ mod runtime {
9696
}
9797
}
9898

99-
#[cfg(all(feature = "async-std"))]
100-
mod runtime {
99+
#[cfg(feature = "async-std")]
100+
mod internal {
101101
use super::*;
102102
use async_std::task;
103103

104+
/// Simple handler for spawning task.
104105
#[derive(Clone)]
105106
pub struct TaskExecutor;
106107

107108
impl TaskExecutor {
109+
/// Spawns a future onto async-std runtime.
108110
pub fn spawn<F>(&self, future: F)
109111
where
110112
F: Future + Send + 'static,
@@ -114,24 +116,30 @@ mod runtime {
114116
}
115117
}
116118

119+
/// Wrapper of the async-std runtime.
117120
pub struct Runtime(TaskExecutor);
118121

119122
impl Runtime {
123+
/// Creates a new [`Runtime`].
120124
pub fn new() -> Option<Self> {
121125
Some(Runtime(TaskExecutor))
122126
}
123127

128+
/// Returns a spawner.
124129
pub fn handle(&self) -> &TaskExecutor {
125130
&self.0
126131
}
127132

133+
/// Runs a future to completion on the async-std runtime. This is the
134+
/// runtime's entry point.
128135
pub fn block_on<F, T>(&mut self, future: F) -> T
129136
where
130137
F: Future<Output = T>,
131138
{
132139
task::block_on(future)
133140
}
134141

142+
/// Spawns a future onto the async-std runtime.
135143
pub fn spawn<F, T>(&self, future: F)
136144
where
137145
F: Future<Output = T> + Send + 'static,
@@ -141,10 +149,12 @@ mod runtime {
141149
}
142150
}
143151

152+
/// The default executor of async-std.
144153
#[derive(Clone)]
145154
pub struct DefaultExecutor;
146155

147156
impl DefaultExecutor {
157+
/// The default executor of async-std.
148158
pub fn current() -> Self {
149159
Self {}
150160
}

src/time.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::Error;
22
use futures_util::{select, FutureExt};
33
use std::future::Future;
44
use std::time::Duration;
5-
pub use time::{delay_for, interval};
5+
6+
pub use internal::{delay_for, interval};
67

78
pub(crate) async fn timeout<F, T, E>(duration: Duration, f: F) -> Result<T, Error<E>>
89
where
@@ -14,7 +15,7 @@ where
1415
}
1516
}
1617

17-
mod time {
18+
mod internal {
1819
use std::time::Duration;
1920
use std::time::Instant;
2021

0 commit comments

Comments
 (0)