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:
parent
82bde8d166
commit
4c6cb6e359
@ -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! {
|
||||||
.unwrap_or_else(|| {
|
|
||||||
quote! {
|
|
||||||
#[allow(unknown_lints)]
|
#[allow(unknown_lints)]
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
|
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
|
||||||
#[allow(rust_2018_idioms)]
|
#[allow(rust_2018_idioms)]
|
||||||
extern crate serde as _serde;
|
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)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user