#[non_exhaustive]pub struct Divergence {
pub at: usize,
pub old: Option<(Vec<u8>, Vec<u8>)>,
pub new: Option<(Vec<u8>, Vec<u8>)>,
}Expand description
What one comparison found.
use kevy_cli::Reply;
use kevy_cli::shadow::{Shape, compare, rows_of};
let old = rows_of(&Reply::Array(vec![Reply::Bulk(b"a".to_vec()), Reply::Bulk(b"b".to_vec())]), Shape::Flat);
let new = rows_of(&Reply::Array(vec![Reply::Bulk(b"b".to_vec()), Reply::Bulk(b"a".to_vec())]), Shape::Flat);
let d = compare(&old, &new).first.expect("same rows, different order");
assert_eq!((d.at, d.old.map(|r| r.0), d.new.map(|r| r.0)), (0, Some(b"a".to_vec()), Some(b"b".to_vec())));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.at: usizePosition of the first place the two orders differ.
use kevy_cli::Reply;
use kevy_cli::shadow::{Shape, compare, rows_of};
let old = rows_of(&Reply::Array(vec![Reply::Bulk(b"a".to_vec()), Reply::Bulk(b"b".to_vec())]), Shape::Flat);
let new = rows_of(&Reply::Array(vec![Reply::Bulk(b"a".to_vec()), Reply::Bulk(b"c".to_vec())]), Shape::Flat);
assert_eq!(compare(&old, &new).first.map(|d| d.at), Some(1));old: Option<(Vec<u8>, Vec<u8>)>The old side’s row and the value it was ordered by.
use kevy_cli::Reply;
use kevy_cli::shadow::{Shape, compare, rows_of};
let old = rows_of(&Reply::Array(vec![Reply::Bulk(b"a".to_vec()), Reply::Bulk(b"5".to_vec())]), Shape::Pairs);
let new = rows_of(&Reply::Array(vec![]), Shape::Pairs);
let d = compare(&old, &new).first.unwrap();
assert_eq!(d.old, Some((b"a".to_vec(), b"5".to_vec())), "the row and its sort value");new: Option<(Vec<u8>, Vec<u8>)>The new side’s, at the same position.
use kevy_cli::Reply;
use kevy_cli::shadow::{Shape, compare, rows_of};
let old = rows_of(&Reply::Array(vec![Reply::Bulk(b"a".to_vec())]), Shape::Flat);
let new = rows_of(&Reply::Array(vec![Reply::Bulk(b"a".to_vec()), Reply::Bulk(b"b".to_vec())]), Shape::Flat);
let d = compare(&old, &new).first.unwrap();
assert_eq!(d.new, Some((b"b".to_vec(), vec![])));
assert_eq!(d.old, None, "the old side ended here");Trait Implementations§
Source§impl Clone for Divergence
impl Clone for Divergence
Source§impl Debug for Divergence
impl Debug for Divergence
Source§impl Default for Divergence
impl Default for Divergence
impl Eq for Divergence
Source§impl Hash for Divergence
impl Hash for Divergence
Source§impl PartialEq for Divergence
impl PartialEq for Divergence
impl StructuralPartialEq for Divergence
Auto Trait Implementations§
impl Freeze for Divergence
impl RefUnwindSafe for Divergence
impl Send for Divergence
impl Sync for Divergence
impl Unpin for Divergence
impl UnsafeUnpin for Divergence
impl UnwindSafe for Divergence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more