Remove unnecessary lifetime parameter from Dependencies

This commit is contained in:
Tavian Barnes
2024-07-27 19:49:58 -04:00
parent c4a56e9c3f
commit 8771861b0c
3 changed files with 20 additions and 20 deletions
+2 -2
View File
@@ -72,11 +72,11 @@ use super::{Config, Dependencies};
pub struct MatcherIO<'a> {
should_skip_dir: bool,
quit: bool,
deps: &'a dyn Dependencies<'a>,
deps: &'a dyn Dependencies,
}
impl<'a> MatcherIO<'a> {
pub fn new(deps: &'a dyn Dependencies<'a>) -> MatcherIO<'a> {
pub fn new(deps: &dyn Dependencies) -> MatcherIO<'_> {
MatcherIO {
deps,
should_skip_dir: false,
+13 -13
View File
@@ -46,9 +46,9 @@ impl Default for Config {
/// Trait that encapsulates various dependencies (output, clocks, etc.) that we
/// might want to fake out for unit tests.
pub trait Dependencies<'a> {
fn get_output(&'a self) -> &'a RefCell<dyn Write>;
fn now(&'a self) -> SystemTime;
pub trait Dependencies {
fn get_output(&self) -> &RefCell<dyn Write>;
fn now(&self) -> SystemTime;
}
/// Struct that holds the dependencies we use when run as the real executable.
@@ -73,12 +73,12 @@ impl Default for StandardDependencies {
}
}
impl<'a> Dependencies<'a> for StandardDependencies {
fn get_output(&'a self) -> &'a RefCell<dyn Write> {
impl Dependencies for StandardDependencies {
fn get_output(&self) -> &RefCell<dyn Write> {
self.output.as_ref()
}
fn now(&'a self) -> SystemTime {
fn now(&self) -> SystemTime {
self.now
}
}
@@ -135,10 +135,10 @@ fn parse_args(args: &[&str]) -> Result<ParsedInfo, Box<dyn Error>> {
})
}
fn process_dir<'a>(
fn process_dir(
dir: &str,
config: &Config,
deps: &'a dyn Dependencies<'a>,
deps: &dyn Dependencies,
matcher: &dyn matchers::Matcher,
quit: &mut bool,
) -> u64 {
@@ -180,7 +180,7 @@ fn process_dir<'a>(
found_count
}
fn do_find<'a>(args: &[&str], deps: &'a dyn Dependencies<'a>) -> Result<u64, Box<dyn Error>> {
fn do_find(args: &[&str], deps: &dyn Dependencies) -> Result<u64, Box<dyn Error>> {
let paths_and_matcher = parse_args(args)?;
if paths_and_matcher.config.help_requested {
print_help();
@@ -263,7 +263,7 @@ fn print_version() {
/// All main has to do is pass in the command-line args and exit the process
/// with the exit code. Note that the first string in args is expected to be
/// the name of the executable.
pub fn find_main<'a>(args: &[&str], deps: &'a dyn Dependencies<'a>) -> i32 {
pub fn find_main(args: &[&str], deps: &dyn Dependencies) -> i32 {
match do_find(&args[1..], deps) {
Ok(_) => uucore::error::get_exit_code(),
Err(e) => {
@@ -336,12 +336,12 @@ mod tests {
}
}
impl<'a> Dependencies<'a> for FakeDependencies {
fn get_output(&'a self) -> &'a RefCell<dyn Write> {
impl Dependencies for FakeDependencies {
fn get_output(&self) -> &RefCell<dyn Write> {
&self.output
}
fn now(&'a self) -> SystemTime {
fn now(&self) -> SystemTime {
self.now
}
}
+5 -5
View File
@@ -21,7 +21,7 @@ pub struct FakeDependencies {
now: SystemTime,
}
impl<'a> FakeDependencies {
impl FakeDependencies {
pub fn new() -> Self {
Self {
output: RefCell::new(Cursor::new(Vec::<u8>::new())),
@@ -29,7 +29,7 @@ impl<'a> FakeDependencies {
}
}
pub fn new_matcher_io(&'a self) -> MatcherIO<'a> {
pub fn new_matcher_io(&self) -> MatcherIO<'_> {
MatcherIO::new(self)
}
@@ -42,12 +42,12 @@ impl<'a> FakeDependencies {
}
}
impl<'a> Dependencies<'a> for FakeDependencies {
fn get_output(&'a self) -> &'a RefCell<dyn Write> {
impl Dependencies for FakeDependencies {
fn get_output(&self) -> &RefCell<dyn Write> {
&self.output
}
fn now(&'a self) -> SystemTime {
fn now(&self) -> SystemTime {
self.now
}
}