fn unify(&self, other: &Self) -> TractResult<Self> {
        let (x, y) = (self, other);

        use itertools::EitherOrBoth::{Both, Left, Right};
        use itertools::Itertools;

        let xi = x.dims();
        let yi = y.dims();

        let dimensions: TVec<_> = xi
            .zip_longest(yi)
            .map(|r| match r {
                Both(a, b) => a.unify(&b),
                Left(d) if y.open => Ok(d),
                Right(d) if x.open => Ok(d),

                Left(_) | Right(_) => bail!(
                    "Impossible to unify closed shapes of different rank (found {:?} and {:?}).",
                    x,
                    y
                ),
            })
            .collect::<TractResult<_>>()
            .map_err(|e| format!("Unifying shapes {:?} and {:?}, {}", x, y, e))?;

        if x.open && y.open {
            Ok(ShapeFact::open(dimensions))
        } else {
            Ok(ShapeFact::closed(dimensions))
        }
    }
/// Tries to unify the fact with another fact of the same type.
Tries to unify the fact with another fact of the same type.
Tries to unify the fact with another fact of the same type .
fn unify(&self, other: &Self) -> TractResult<Self> {
        let (x, y) = (self, other);
        use itertools::EitherOrBoth::{Both, Left, Right};
        use itertools::Itertools;
        let xi = x.dims();
        let yi = y.dims();
        let dimensions: TVec<_> = xi
            .zip_longest(yi)
            .map(|r| match r {
                Both(a, b) => a.unify(&b),
                Left(d) if y.open => Ok(d),
                Right(d) if x.open => Ok(d),
                Left(_) | Right(_) => bail!(
                    "Impossible to unify closed shapes of different rank (found {:?} and {:?}).",
                    x,
                    y
                ),
            })
            .collect::<TractResult<_>>()
            .map_err(|e| format!("Unifying shapes {:?} and {:?}, {}", x, y, e))?;
        if x.open && y.open {
            Ok(ShapeFact::open(dimensions))
        } else {
            Ok(ShapeFact::closed(dimensions))
        }
    }
fn unify ( & self , other : & Self ) -> TractResult < Self > { let ( x , y ) = ( self , other ) ; use itertools :: EitherOrBoth :: { Both , Left , Right } ; use itertools :: Itertools ; let xi = x . dims ( ) ; let yi = y . dims ( ) ; let dimensions : TVec < _ > = xi . zip_longest ( yi ) . map ( | r | match r { Both ( a , b ) => a . unify ( & b ) , Left ( d ) if y . open => Ok ( d ) , Right ( d ) if x . open => Ok ( d ) , Left ( _ ) | Right ( _ ) => bail ! ( " " x y ) , } ) . collect :: < TractResult < _ > > ( ) . map_err ( | e | format ! ( " " x y e ) ) ? ; if x . open && y . open { Ok ( ShapeFact :: open ( dimensions ) ) } else { Ok ( ShapeFact :: closed ( dimensions ) ) } }
Tries to unify the fact with another fact of the same type.
Tries to unify the fact with another fact of the same type .
&self
other
&Self
&self
other
&Self