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 Freeze for DeprecatedWarningBuilder
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