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
impl DeprecatedWarningBuilder
sourcepub fn from_title(title: &str) -> DeprecatedWarningBuilder
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.
sourcepub fn index(self, index: usize) -> DeprecatedWarningBuilder
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.
sourcepub fn old(self, old: &str) -> DeprecatedWarningBuilder
pub fn old(self, old: &str) -> DeprecatedWarningBuilder
The old deprecated way of doing something.
Should complete the sentence “It is deprecated to …”.
sourcepub fn new(self, new: &str) -> DeprecatedWarningBuilder
pub fn new(self, new: &str) -> DeprecatedWarningBuilder
The new way of doing something.
Should complete the sentence “Please instead …”.
sourcepub fn help_link(self, link: &str) -> DeprecatedWarningBuilder
pub fn help_link(self, link: &str) -> DeprecatedWarningBuilder
A help link for the user to explain the transition and justification.
sourcepub fn help_links(self, links: &[&str]) -> DeprecatedWarningBuilder
pub fn help_links(self, links: &[&str]) -> DeprecatedWarningBuilder
Multiple help links for the user to explain the transition and justification.
sourcepub fn span(self, span: Span) -> DeprecatedWarningBuilder
pub fn span(self, span: Span) -> DeprecatedWarningBuilder
The span of the warning.
sourcepub fn maybe_build(self) -> Result<Warning, String>
pub fn maybe_build(self) -> Result<Warning, String>
Build the warning.
sourcepub fn build(self) -> Warning
pub fn build(self) -> Warning
Unwraps Self::maybe_build
for convenience.
Trait Implementations§
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