mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 16:21:03 +00:00
Match on serde_path to handle Some(path) and None
I find this a bit easier to follow than map + unwrap_or_else.
This commit is contained in:
+11
-14
@@ -16,20 +16,17 @@ pub fn wrap_in_const(
|
|||||||
Span::call_site(),
|
Span::call_site(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let use_serde = serde_path
|
let use_serde = match serde_path {
|
||||||
.map(|path| {
|
Some(path) => quote! {
|
||||||
quote! {
|
use #path as _serde;
|
||||||
use #path as _serde;
|
},
|
||||||
}
|
None => quote! {
|
||||||
})
|
#[allow(unknown_lints)]
|
||||||
.unwrap_or_else(|| {
|
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
|
||||||
quote! {
|
#[allow(rust_2018_idioms)]
|
||||||
#[allow(unknown_lints)]
|
extern crate serde as _serde;
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
|
},
|
||||||
#[allow(rust_2018_idioms)]
|
};
|
||||||
extern crate serde as _serde;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
|
|||||||
Reference in New Issue
Block a user