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>,
) -> Suggestion
pub fn new( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Suggestion
Create a new suggestion with unspecified applicability.
Sourcepub fn machine_applicable(
message: impl Into<String>,
span: Span,
replacement: impl Into<String>,
) -> Suggestion
pub fn machine_applicable( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Suggestion
Create a suggestion that is safe to auto-apply.
Sourcepub fn maybe_incorrect(
message: impl Into<String>,
span: Span,
replacement: impl Into<String>,
) -> Suggestion
pub fn maybe_incorrect( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Suggestion
Create a suggestion that may need human review.
Sourcepub fn with_placeholders(
message: impl Into<String>,
span: Span,
replacement: impl Into<String>,
) -> Suggestion
pub fn with_placeholders( message: impl Into<String>, span: Span, replacement: impl Into<String>, ) -> Suggestion
Create a suggestion with placeholders.
Sourcepub fn with_applicability(self, applicability: Applicability) -> Suggestion
pub fn with_applicability(self, applicability: Applicability) -> Suggestion
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
An iterator over the items within this container, by reference.
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
Check whether an item is contained within this sequence.
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
Convert an item of the sequence into a [
MaybeRef].