Skip to content

Commit e99ee7d

Browse files
committed
fix: lints+formatting+docs
1 parent e2b907d commit e99ee7d

9 files changed

Lines changed: 31 additions & 14 deletions

File tree

clippy_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ cargo clippy --all -- \
3232
-A clippy::absolute_paths \
3333
-A clippy::let_underscore_untyped \
3434
-A clippy::missing_docs_in_private_items \
35-
-A clippy::items_after_statements
35+
-A clippy::items_after_statements \
36+
-A clippy::mod_module_files

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub struct SearchConfig {
109109
}
110110
impl SearchConfig {
111111
/**
112-
Constructor for SearchConfig
112+
Constructor for `SearchConfig`
113113
114114
Builds a regex matcher if a valid pattern is provided, otherwise stores None
115115
Returns an error if the regex compilation fails

src/filters/time_filter.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use clap::{
33
builder::{PossibleValue, TypedValueParser},
44
error::{ContextKind, ContextValue, ErrorKind},
55
};
6-
use std::{
7-
ffi::OsStr,
8-
fmt,
9-
time::{Duration, SystemTime},
10-
};
6+
use core::time::Duration;
7+
use std::{ffi::OsStr, fmt, time::SystemTime};
118

129
#[derive(Debug, Clone, PartialEq, Eq)]
1310
#[allow(clippy::exhaustive_enums)]
@@ -61,7 +58,7 @@ pub enum TimeFilter {
6158

6259
impl TimeFilter {
6360
/**
64-
Parses a time string and returns a `TimeFilter`
61+
Parses a time string and returns a `TimeFilter`.
6562
6663
# Arguments
6764
@@ -75,6 +72,24 @@ impl TimeFilter {
7572
- `..` separator: between two times (e.g., "2d..1d" = files modified between 2 days and 1 day ago)
7673
- Supported units: s (seconds), m (minutes), h (hours), d (days), w (weeks), y (years)
7774
75+
# Examples
76+
77+
```
78+
use fdf::filters::TimeFilter;
79+
80+
// Files modified within the last hour
81+
let filter = TimeFilter::from_string("-1h").unwrap();
82+
83+
// Files modified more than 2 days ago
84+
let filter = TimeFilter::from_string("+2d").unwrap();
85+
86+
// Files modified between 2 days and 1 day ago
87+
let filter = TimeFilter::from_string("2d..1d").unwrap();
88+
```
89+
90+
# Errors
91+
92+
Returns `ParseTimeError::InvalidFormat` if the string cannot be parsed or is in an invalid format.
7893
*/
7994
pub fn from_string(s: &str) -> Result<Self, ParseTimeError> {
8095
Self::parse_args(s).ok_or(ParseTimeError::InvalidFormat)

src/fs/buffer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ where
178178
#[cfg(any(target_os = "linux", target_os = "android"))]
179179
pub fn getdents(&mut self, fd: &crate::fs::FileDes) -> i64 {
180180
// SAFETY: we're passing a valid buffer
181-
unsafe {
182-
crate::util::getdents(fd.0, self.as_mut_ptr(), SIZE) }
181+
unsafe { crate::util::getdents(fd.0, self.as_mut_ptr(), SIZE) }
183182
}
184183

185184
// TODO: Maybe delete this?

src/fs/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ pub trait DirentConstructor {
503503
This allows no dynamic resizing during iteration, which is costly!
504504
*/
505505

506-
// SAFETY: write is within buffer bounds
507506
#[allow(clippy::multiple_unsafe_ops_per_block)] //dumb
507+
// SAFETY: write is within buffer bounds
508508
unsafe {
509509
*path_buffer.as_mut_ptr().add(base_len) = b'/' * (!is_root as u8) // add slash if needed (this avoids a branch )
510510
};

src/util/glob.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use std::vec::IntoIter as VecIntoIter;
6161
/// Error type for glob pattern operations
6262
#[allow(clippy::error_impl_error)]
6363
#[derive(Debug)]
64+
#[non_exhaustive]
6465
pub enum Error {
6566
/// Bare escape at the end of the pattern
6667
BareEscape,

src/util/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::dirent64;
2-
use crate::{util::memchr_derivations::memrchr};
2+
use crate::util::memchr_derivations::memrchr;
33
use core::ops::Deref;
44

5-
/*
5+
/**
66
Wrapper for direct getdents syscalls
77
88

src/walk/finder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
walk::{DirEntryFilter, FilterType, finder_builder::FinderBuilder},
66
};
77
use dashmap::DashSet;
8-
use rayon::iter::{IntoParallelIterator, ParallelIterator};
8+
use rayon::iter::{IntoParallelIterator as _, ParallelIterator as _};
99
use std::{
1010
ffi::OsStr,
1111
sync::{

src/walk/finder_builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ impl FinderBuilder {
207207
}
208208

209209
/// Set how many threads rayon is to use, defaults to max
210+
#[must_use]
210211
pub const fn thread_count(mut self, threads: Option<usize>) -> Self {
211212
match threads {
212213
Some(num) => self.thread_count = num,

0 commit comments

Comments
 (0)