Skip to content

Commit 03d1910

Browse files
Fix some clippy warnings
1 parent 09f2c5f commit 03d1910

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+172
-132
lines changed

examples/a-chat/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>
55

66
fn main() -> Result<()> {
77
let mut args = std::env::args();
8-
match (args.nth(1).as_ref().map(String::as_str), args.next()) {
8+
match (args.nth(1).as_deref(), args.next()) {
99
(Some("client"), None) => client::main(),
1010
(Some("server"), None) => server::main(),
1111
_ => Err("Usage: a-chat [client|server]".into()),

src/fs/dir_builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ impl DirBuilder {
3636
///
3737
/// let builder = DirBuilder::new();
3838
/// ```
39-
pub fn new() -> DirBuilder {
39+
#[must_use]
40+
pub const fn new() -> DirBuilder {
4041
#[cfg(not(unix))]
4142
let builder = DirBuilder { recursive: false };
4243

src/fs/dir_entry.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl DirEntry {
4747
/// #
4848
/// # Ok(()) }) }
4949
/// ```
50+
#[must_use]
5051
pub fn path(&self) -> PathBuf {
5152
self.0.path().into()
5253
}
@@ -147,6 +148,7 @@ impl DirEntry {
147148
/// #
148149
/// # Ok(()) }) }
149150
/// ```
151+
#[must_use]
150152
pub fn file_name(&self) -> OsString {
151153
self.0.file_name()
152154
}

src/fs/file.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ impl LockGuard<State> {
871871

872872
// This function does nothing because we're not sure about `AsyncWrite::poll_close()`'s exact
873873
// semantics nor whether it will stay in the `AsyncWrite` trait.
874+
#[allow(clippy::unused_self)]
874875
fn poll_close(self, _: &mut Context<'_>) -> Poll<io::Result<()>> {
875876
Poll::Ready(Ok(()))
876877
}
@@ -899,7 +900,8 @@ mod tests {
899900
drop(clone);
900901
buf.len()
901902
})
902-
}).await;
903+
})
904+
.await;
903905
assert_eq!(len as u64, file.metadata().await.unwrap().len());
904906
});
905907
}

src/fs/open_options.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl OpenOptions {
8080
/// #
8181
/// # Ok(()) }) }
8282
/// ```
83+
#[must_use]
8384
pub fn new() -> OpenOptions {
8485
OpenOptions(std::fs::OpenOptions::new())
8586
}

src/fs/read_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ enum State {
8080

8181
impl ReadDir {
8282
/// Creates an asynchronous `ReadDir` from a synchronous handle.
83-
pub(crate) fn new(inner: std::fs::ReadDir) -> ReadDir {
83+
pub(crate) const fn new(inner: std::fs::ReadDir) -> ReadDir {
8484
ReadDir(State::Idle(Some(inner)))
8585
}
8686
}

src/io/buf_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<R> BufReader<R> {
115115
/// #
116116
/// # Ok(()) }) }
117117
/// ```
118-
pub fn get_ref(&self) -> &R {
118+
pub const fn get_ref(&self) -> &R {
119119
&self.inner
120120
}
121121

src/io/buf_writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<W: Write> BufWriter<W> {
211211
self.project().inner
212212
}
213213

214-
/// Consumes BufWriter, returning the underlying writer
214+
/// Consumes `BufWriter`, returning the underlying writer
215215
///
216216
/// This method will not write leftover data, it will be lost.
217217
/// For method that will attempt to write before returning the writer see [`poll_into_inner`]
@@ -263,7 +263,7 @@ impl<W: Write> BufWriter<W> {
263263

264264
/// Poll buffer flushing until completion
265265
///
266-
/// This is used in types that wrap around BufWrite, one such example: [`LineWriter`]
266+
/// This is used in types that wrap around `BufWrite`, one such example: [`LineWriter`]
267267
///
268268
/// [`LineWriter`]: struct.LineWriter.html
269269
fn poll_flush_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {

src/io/empty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ use crate::task::{Context, Poll};
2222
/// #
2323
/// # Ok(()) }) }
2424
/// ```
25-
pub fn empty() -> Empty {
25+
#[must_use]
26+
pub const fn empty() -> Empty {
2627
Empty { _private: () }
2728
}
2829

src/io/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//! nickname: readers and writers. So you'll sometimes see 'a reader' instead
4040
//! of 'a type that implements the [`Read`] trait'. Much easier!
4141
//!
42-
//! ## Seek and BufRead
42+
//! ## `Seek` and `BufRead`
4343
//!
4444
//! Beyond that, there are two important traits that are provided: [`Seek`]
4545
//! and [`BufRead`]. Both of these build on top of a reader to control
@@ -70,7 +70,7 @@
7070
//! [`BufRead`] uses an internal buffer to provide a number of other ways to read, but
7171
//! to show it off, we'll need to talk about buffers in general. Keep reading!
7272
//!
73-
//! ## BufReader and BufWriter
73+
//! ## `BufReader` and `BufWriter`
7474
//!
7575
//! Byte-based interfaces are unwieldy and can be inefficient, as we'd need to be
7676
//! making near-constant calls to the operating system. To help with this,
@@ -214,7 +214,7 @@
214214
//!
215215
//! [functions-list]: #functions-1
216216
//!
217-
//! ## io::Result
217+
//! ## `io::Result`
218218
//!
219219
//! Last, but certainly not least, is [`io::Result`]. This type is used
220220
//! as the return type of many `std::io` functions that can cause an error, and

0 commit comments

Comments
 (0)