Remove lifetimes from Printer (#2704)

This commit is contained in:
Charlie Marsh 2023-02-09 21:44:15 -05:00 committed by GitHub
parent 41c0608a69
commit 5437f1299b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View file

@ -185,7 +185,7 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
return Ok(ExitStatus::Success);
}
let printer = Printer::new(&format, &log_level, &autofix, &violations);
let printer = Printer::new(format, log_level, autofix, violations);
if cli.watch {
if !matches!(autofix, fix::FixMode::None) {

View file

@ -68,19 +68,19 @@ impl<'a> From<&'a Rule> for SerializeRuleAsCode<'a> {
}
}
pub struct Printer<'a> {
format: &'a SerializationFormat,
log_level: &'a LogLevel,
autofix: &'a fix::FixMode,
violations: &'a Violations,
pub struct Printer {
format: SerializationFormat,
log_level: LogLevel,
autofix: fix::FixMode,
violations: Violations,
}
impl<'a> Printer<'a> {
impl Printer {
pub const fn new(
format: &'a SerializationFormat,
log_level: &'a LogLevel,
autofix: &'a fix::FixMode,
violations: &'a Violations,
format: SerializationFormat,
log_level: LogLevel,
autofix: fix::FixMode,
violations: Violations,
) -> Self {
Self {
format,
@ -91,13 +91,13 @@ impl<'a> Printer<'a> {
}
pub fn write_to_user(&self, message: &str) {
if self.log_level >= &LogLevel::Default {
if self.log_level >= LogLevel::Default {
notify_user!("{}", message);
}
}
fn post_text<T: Write>(&self, stdout: &mut T, diagnostics: &Diagnostics) -> Result<()> {
if self.log_level >= &LogLevel::Default {
if self.log_level >= LogLevel::Default {
match self.violations {
Violations::Show => {
let fixed = diagnostics.fixed;
@ -445,7 +445,7 @@ impl<'a> Printer<'a> {
return Ok(());
}
if self.log_level >= &LogLevel::Default {
if self.log_level >= LogLevel::Default {
let s = if diagnostics.messages.len() == 1 {
""
} else {
@ -459,7 +459,7 @@ impl<'a> Printer<'a> {
let mut stdout = BufWriter::new(io::stdout().lock());
if !diagnostics.messages.is_empty() {
if self.log_level >= &LogLevel::Default {
if self.log_level >= LogLevel::Default {
writeln!(stdout)?;
}
for message in &diagnostics.messages {