From c620d263da47edb5bea07f20d1abebae500e6da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noah=20H=C3=BCsser?= Date: Tue, 26 Dec 2023 16:06:16 +0100 Subject: [PATCH] Make the diff and Difference symbols public --- src/diff.rs | 6 ++++-- src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) 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;