Struct DeprecatedWarningBuilder

Source
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

Source§

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>,

Source§

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>,

Source§

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.