pub struct Suggestion {
pub message: String,
pub span: Span,
pub replacement: String,
pub applicability: Applicability,
}Expand description
A suggested code fix that can be applied to resolve a diagnostic.
Suggestions provide machine-readable fix information that IDEs and tools can use to offer quick-fix actions.
Fields§
§message: StringHuman-readable description of what the suggestion does.
span: SpanThe span of code to replace.
replacement: StringThe replacement text.
applicability: ApplicabilityHow confident we are that this fix is correct.
Implementations§
Source§impl Suggestion
impl Suggestion
Sourcepub fn new(
message: impl Into<String>,
span: Span,
replacement: impl Into<String>,
) -> Self
pub fn new( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Self
Create a new suggestion with unspecified applicability.
Sourcepub fn machine_applicable(
message: impl Into<String>,
span: Span,
replacement: impl Into<String>,
) -> Self
pub fn machine_applicable( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Self
Create a suggestion that is safe to auto-apply.
Sourcepub fn maybe_incorrect(
message: impl Into<String>,
span: Span,
replacement: impl Into<String>,
) -> Self
pub fn maybe_incorrect( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Self
Create a suggestion that may need human review.
Sourcepub fn with_placeholders(
message: impl Into<String>,
span: Span,
replacement: impl Into<String>,
) -> Self
pub fn with_placeholders( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Self
Create a suggestion with placeholders.
Sourcepub fn with_applicability(self, applicability: Applicability) -> Self
pub fn with_applicability(self, applicability: Applicability) -> Self
Set the applicability of this suggestion.
Trait Implementations§
Source§impl Clone for Suggestion
impl Clone for Suggestion
Source§fn clone(&self) -> Suggestion
fn clone(&self) -> Suggestion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Suggestion
impl RefUnwindSafe for Suggestion
impl Send for Suggestion
impl Sync for Suggestion
impl Unpin for Suggestion
impl UnwindSafe for Suggestion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more