mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Document how style traits can be derived
This commit is contained in:
parent
41c3be54ea
commit
ba4136b5a8
4 changed files with 44 additions and 3 deletions
|
@ -10,6 +10,17 @@ use std::iter::Sum;
|
|||
use std::ops::Add;
|
||||
|
||||
/// A trait to compute squared distances between two animatable values.
|
||||
///
|
||||
/// This trait is derivable with `#[derive(ComputeSquaredDistance)]`. The derived
|
||||
/// implementation uses a `match` expression with identical patterns for both
|
||||
/// `self` and `other`, calling `ComputeSquaredDistance::compute_squared_distance`
|
||||
/// on each fields of the values.
|
||||
///
|
||||
/// If a variant is annotated with `#[animation(error)]`, the corresponding
|
||||
/// `match` arm is not generated.
|
||||
///
|
||||
/// If the two values are not similar, an error is returned unless a fallback
|
||||
/// function has been specified through `#[distance(fallback)]`.
|
||||
pub trait ComputeSquaredDistance {
|
||||
/// Computes the squared distance between two animatable values.
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue