mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Implement #[animate(fallback)] for #[derive(Animate)]
This allows us to derive the Animate trait, providing a fallback function for when the 2 values aren't similar.
This commit is contained in:
parent
3751fe9fdc
commit
4a4bf89575
7 changed files with 99 additions and 121 deletions
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use animate::AnimateAttrs;
|
||||
use animate::AnimationVariantAttrs;
|
||||
use cg;
|
||||
use quote;
|
||||
use syn;
|
||||
|
@ -17,7 +17,7 @@ pub fn derive(input: syn::DeriveInput) -> quote::Tokens {
|
|||
let mut match_body = quote!();
|
||||
let mut append_error_clause = variants.len() > 1;
|
||||
match_body.append_all(variants.iter().map(|variant| {
|
||||
let attrs = cg::parse_variant_attrs::<AnimateAttrs>(variant);
|
||||
let attrs = cg::parse_variant_attrs::<AnimationVariantAttrs>(variant);
|
||||
if attrs.error {
|
||||
append_error_clause = true;
|
||||
return None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue