fn find_mismatch<'a>(expected: &'a Json, actual: &'a Json) -> Option<(&'a Json, &'a Json)> {
    use rustc_serialize::json::Json::*;
    match (expected, actual) {
        (&I64(l), &I64(r)) if l == r => None,
        (&F64(l), &F64(r)) if l == r => None,
        (&U64(l), &U64(r)) if l == r => None,
        (&Boolean(l), &Boolean(r)) if l == r => None,
        (&String(ref l), &String(ref r)) if lines_match(l, r) => None,
        (&Array(ref l), &Array(ref r)) => {
            if l.len() != r.len() {
                return Some((expected, actual));
            }

            fn sorted(xs: &Vec<Json>) -> Vec<&Json> {
                let mut result = xs.iter().collect::<Vec<_>>();
                // `unwrap` should be safe because JSON spec does not allow NaNs
                result.sort_by(|x, y| x.partial_cmp(y).unwrap());
                result
            }

            sorted(l).iter().zip(sorted(r))
             .filter_map(|(l, r)| find_mismatch(l, r))
             .nth(0)
        }
        (&Object(ref l), &Object(ref r)) => {
            let same_keys = l.len() == r.len() && l.keys().all(|k| r.contains_key(k));
            if !same_keys {
                return Some((expected, actual));
            }

            l.values().zip(r.values())
             .filter_map(|(l, r)| find_mismatch(l, r))
             .nth(0)
        }
        (&Null, &Null) => None,
        _ => Some((expected, actual)),
    }

}
// Compares JSON object for approximate equality.
// You can use `[..]` wildcard in strings (useful for OS dependent things such as paths).
// Arrays are sorted before comparison.
Compares JSON object for approximate equality.
You can use `[..]` wildcard in strings (useful for OS dependent things such as paths).
Arrays are sorted before comparison.
Compares JSON object for approximate equality . You can use ` [ .. ] ` wildcard in strings ( useful for OS dependent things such as paths ) . Arrays are sorted before comparison .
fn find_mismatch<'a>(expected: &'a Json, actual: &'a Json) -> Option<(&'a Json, &'a Json)> {
    use rustc_serialize::json::Json::*;
    match (expected, actual) {
        (&I64(l), &I64(r)) if l == r => None,
        (&F64(l), &F64(r)) if l == r => None,
        (&U64(l), &U64(r)) if l == r => None,
        (&Boolean(l), &Boolean(r)) if l == r => None,
        (&String(ref l), &String(ref r)) if lines_match(l, r) => None,
        (&Array(ref l), &Array(ref r)) => {
            if l.len() != r.len() {
                return Some((expected, actual));
            }
            fn sorted(xs: &Vec<Json>) -> Vec<&Json> {
                let mut result = xs.iter().collect::<Vec<_>>();
                // `unwrap` should be safe because JSON spec does not allow NaNs
                result.sort_by(|x, y| x.partial_cmp(y).unwrap());
                result
            }
            sorted(l).iter().zip(sorted(r))
             .filter_map(|(l, r)| find_mismatch(l, r))
             .nth(0)
        }
        (&Object(ref l), &Object(ref r)) => {
            let same_keys = l.len() == r.len() && l.keys().all(|k| r.contains_key(k));
            if !same_keys {
                return Some((expected, actual));
            }
            l.values().zip(r.values())
             .filter_map(|(l, r)| find_mismatch(l, r))
             .nth(0)
        }
        (&Null, &Null) => None,
        _ => Some((expected, actual)),
    }
}
fn find_mismatch < ' a > ( expected : & ' a Json , actual : & ' a Json ) -> Option < ( & ' a Json , & ' a Json ) > { use rustc_serialize :: json :: Json :: * ; match ( expected , actual ) { ( & I64 ( l ) , & I64 ( r ) ) if l == r => None , ( & F64 ( l ) , & F64 ( r ) ) if l == r => None , ( & U64 ( l ) , & U64 ( r ) ) if l == r => None , ( & Boolean ( l ) , & Boolean ( r ) ) if l == r => None , ( & String ( ref l ) , & String ( ref r ) ) if lines_match ( l , r ) => None , ( & Array ( ref l ) , & Array ( ref r ) ) => { if l . len ( ) != r . len ( ) { return Some ( ( expected , actual ) ) ; } fn sorted ( xs : & Vec < Json > ) -> Vec < & Json > { let mut result = xs . iter ( ) . collect :: < Vec < _ > > ( ) ; // `unwrap` should be safe because JSON spec does not allow NaNs result . sort_by ( | x , y | x . partial_cmp ( y ) . unwrap ( ) ) ; result } sorted ( l ) . iter ( ) . zip ( sorted ( r ) ) . filter_map ( | ( l , r ) | find_mismatch ( l , r ) ) . nth ( 0 ) } ( & Object ( ref l ) , & Object ( ref r ) ) => { let same_keys = l . len ( ) == r . len ( ) && l . keys ( ) . all ( | k | r . contains_key ( k ) ) ; if ! same_keys { return Some ( ( expected , actual ) ) ; } l . values ( ) . zip ( r . values ( ) ) . filter_map ( | ( l , r ) | find_mismatch ( l , r ) ) . nth ( 0 ) } ( & Null , & Null ) => None , _ => Some ( ( expected , actual ) ) , } }
Compares JSON object for approximate equality.
Compares JSON object for approximate equality .
expected
&'a Json
actual
&'a Json
expected
&'a Json
actual
&'a Json