mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +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 darling::{FromField, FromVariant};
|
||||
use darling::{FromDeriveInput, FromField, FromVariant};
|
||||
use quote::{ToTokens, Tokens};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashSet;
|
||||
|
@ -276,6 +276,16 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_input_attrs<A>(input: &DeriveInput) -> A
|
||||
where
|
||||
A: FromDeriveInput,
|
||||
{
|
||||
match A::from_derive_input(input) {
|
||||
Ok(attrs) => attrs,
|
||||
Err(e) => panic!("failed to parse input attributes: {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_variant_attrs<A>(variant: &Variant) -> A
|
||||
where
|
||||
A: FromVariant,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue