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_or_panic();

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<S: Into<String>>(title: S) -> Self

Create a new deprecated warning builder with the given title.

The title must be unique for each warning.

source

pub fn index<S: Into<usize>>(self, index: S) -> Self

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<S: Into<String>>(self, old: S) -> Self

The old deprecated way of doing something.

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

source

pub fn new<S: Into<String>>(self, new: S) -> Self

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) -> Self

Set the span of the warning.

source

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

👎Deprecated: Use try_build instead; Will be removed after Q1 2024

Fallibly build a warning.

source

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

Try to build the warning.

source

pub fn build(self) -> Warning

👎Deprecated: Use build_or_panic instead; Will be removed after Q1 2024

Unwraps Self::maybe_build for convenience.

source

pub fn build_or_panic(self) -> Warning

Build the warning or panic if it fails.

Trait Implementations§

source§

impl Clone for DeprecatedWarningBuilder

source§

fn clone(&self) -> DeprecatedWarningBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DeprecatedWarningBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.