pub struct DeprecatedWarningBuilder { /* private fields */ }
Expand description

Gradually build a deprecation Warning.

Example

use proc_macro_warning::Warning;

let warning = Warning::new_deprecated("my_macro")
    .old("my_macro()")
    .new("my_macro::new()")
    .help_link("https:://example.com")
    // Normally you use the input span, but this is an example:
    .span(proc_macro2::Span::call_site())
    .build();

let mut warnings = vec![warning];
// When adding more, you will need to build each with `.index`.

// In a proc macro you can expand them in a private module:
quote::quote! {
    mod warnings {
        #(
            #warnings
        )*
    }
};

Implementations§

source§

impl DeprecatedWarningBuilder

source

pub fn from_title(title: &str) -> DeprecatedWarningBuilder

Create a new deprecated warning builder with the given title.

The title must be unique for each warning.

source

pub fn index(self, index: usize) -> DeprecatedWarningBuilder

Set an optional index in case that a warning appears multiple times.

Must be set if a warning appears multiple times.

source

pub fn old(self, old: &str) -> DeprecatedWarningBuilder

The old deprecated way of doing something.

Should complete the sentence “It is deprecated to …”.

source

pub fn new(self, new: &str) -> DeprecatedWarningBuilder

The new way of doing something.

Should complete the sentence “Please instead …”.

A help link for the user to explain the transition and justification.

Multiple help links for the user to explain the transition and justification.

source

pub fn span(self, span: Span) -> DeprecatedWarningBuilder

The span of the warning.

source

pub fn maybe_build(self) -> Result<Warning, String>

Build the warning.

source

pub fn build(self) -> Warning

Unwraps Self::maybe_build for convenience.

Trait Implementations§

source§

impl Default for DeprecatedWarningBuilder

source§

fn default() -> DeprecatedWarningBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.