mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Implement distance for shadow list.
This commit is contained in:
parent
dc654c9912
commit
41cbd2fa62
1 changed files with 17 additions and 4 deletions
|
@ -104,11 +104,24 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<S> ComputeSquaredDistance for ShadowList<S> {
|
||||
impl<S> ComputeSquaredDistance for ShadowList<S>
|
||||
where
|
||||
S: ComputeSquaredDistance + ToAnimatedZero,
|
||||
{
|
||||
#[inline]
|
||||
fn compute_squared_distance(&self, _other: &Self) -> Result<SquaredDistance, ()> {
|
||||
// FIXME: This should be implemented.
|
||||
Err(())
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
use itertools::{EitherOrBoth, Itertools};
|
||||
|
||||
self.0.iter().zip_longest(other.0.iter()).map(|it| {
|
||||
match it {
|
||||
EitherOrBoth::Both(from, to) => {
|
||||
from.compute_squared_distance(to)
|
||||
},
|
||||
EitherOrBoth::Left(list) | EitherOrBoth::Right(list) => {
|
||||
list.compute_squared_distance(&list.to_animated_zero()?)
|
||||
},
|
||||
}
|
||||
}).sum()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue