Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions harper-core/src/linting/suggestion.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use std::{borrow::Borrow, fmt::Display};
use std::{
borrow::Borrow,
fmt::{Debug, Display},
};

use is_macro::Is;
use serde::{Deserialize, Serialize};

use crate::{Span, case};

/// A suggested edit that could resolve a [`Lint`](super::Lint).
#[derive(Debug, Clone, Serialize, Deserialize, Is, PartialEq, Eq, Hash)]
#[derive(Clone, Serialize, Deserialize, Is, PartialEq, Eq, Hash)]
pub enum Suggestion {
/// Replace the offending text with a specific character sequence.
ReplaceWith(Vec<char>),
Expand Down Expand Up @@ -83,6 +86,15 @@ impl Display for Suggestion {
}
}

// To make debug output more readable.
// The default debug implementation for Vec<char> isn't ideal in this scenario, as it prints
// characters one at a time, line by line.
impl Debug for Suggestion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
<Self as Display>::fmt(self, f)
}
}

pub trait SuggestionCollectionExt {
fn to_replace_suggestions(
self,
Expand Down