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
 
impl DeprecatedWarningBuilder
sourcepub fn from_title<S: Into<String>>(title: S) -> Self
 
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.
sourcepub fn index<S: Into<usize>>(self, index: S) -> Self
 
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.
sourcepub fn old<S: Into<String>>(self, old: S) -> Self
 
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 …”.
sourcepub fn new<S: Into<String>>(self, new: S) -> Self
 
pub fn new<S: Into<String>>(self, new: S) -> Self
The new way of doing something.
Should complete the sentence “Please instead …”.
sourcepub fn help_link<S: Into<String>>(self, link: S) -> Self
 
pub fn help_link<S: Into<String>>(self, link: S) -> Self
A help link for the user to explain the transition and justification.
sourcepub fn help_links(self, links: &[&str]) -> Self
 
pub fn help_links(self, links: &[&str]) -> Self
Multiple help links for the user to explain the transition and justification.
sourcepub fn maybe_build(self) -> Result<Warning, String>
 👎Deprecated: Use try_build instead; Will be removed after Q1 2024
pub fn maybe_build(self) -> Result<Warning, String>
try_build instead; Will be removed after Q1 2024Fallibly build a warning.
sourcepub fn build(self) -> Warning
 👎Deprecated: Use build_or_panic instead; Will be removed after Q1 2024
pub fn build(self) -> Warning
build_or_panic instead; Will be removed after Q1 2024Unwraps Self::maybe_build for convenience.
sourcepub fn build_or_panic(self) -> Warning
 
pub fn build_or_panic(self) -> Warning
Build the warning or panic if it fails.
Trait Implementations§
source§impl Clone for DeprecatedWarningBuilder
 
impl Clone for DeprecatedWarningBuilder
source§fn clone(&self) -> DeprecatedWarningBuilder
 
fn clone(&self) -> DeprecatedWarningBuilder
Returns a copy 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 moresource§impl Debug for DeprecatedWarningBuilder
 
impl Debug for DeprecatedWarningBuilder
source§impl Default for DeprecatedWarningBuilder
 
impl Default for DeprecatedWarningBuilder
source§fn default() -> DeprecatedWarningBuilder
 
fn default() -> DeprecatedWarningBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for DeprecatedWarningBuilder
impl !Send for DeprecatedWarningBuilder
impl !Sync for DeprecatedWarningBuilder
impl Unpin for DeprecatedWarningBuilder
impl UnwindSafe for DeprecatedWarningBuilder
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