diff --git a/src/diff.rs b/src/diff.rs index de97a0d..88a6ca6 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -3,7 +3,8 @@ use crate::{CompareMode, Config, NumericMode}; use serde_json::Value; use std::{collections::HashSet, fmt}; -pub(crate) fn diff<'a>(lhs: &'a Value, rhs: &'a Value, config: Config) -> Vec> { +/// Compare two json values and return a list of differences. +pub fn diff<'a>(lhs: &'a Value, rhs: &'a Value, config: Config) -> Vec> { let mut acc = vec![]; diff_with(lhs, rhs, config, Path::Root, &mut acc); acc @@ -200,8 +201,9 @@ impl<'a, 'b> DiffFolder<'a, 'b> { } } +/// A difference between two json values. #[derive(Debug, PartialEq)] -pub(crate) struct Difference<'a> { +pub struct Difference<'a> { path: Path<'a>, lhs: Option<&'a Value>, rhs: Option<&'a Value>, diff --git a/src/lib.rs b/src/lib.rs index 961b349..64f2b2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -152,7 +152,7 @@ unknown_lints )] -use diff::diff; +pub use diff::{diff, Difference}; use serde::Serialize; mod core_ext;