#[repr(transparent)]pub struct Unordered<T: ?Sized>(pub T);Expand description
Wrapper to view a value without considering the order of the objects entries.
Unordered<T> implements PartialEq/Eq in terms of
UnorderedPartialEq, so { "a": 0, "b": 1 } and { "b": 1, "a": 0 }
compare equal — unlike the derived PartialEq on
Value, which is order-sensitive.
§Example
use jstrict::{json, BorrowUnordered, Unordered};
let a = json!({ "a": 0, "b": 1 });
let b = json!({ "b": 1, "a": 0 });
assert_ne!(a, b);
assert_eq!(a.as_unordered(), b.as_unordered());
assert_eq!(Unordered(a), Unordered(b));Tuple Fields§
§0: TTrait Implementations§
impl<T: UnorderedEq> Eq for Unordered<T>
Source§impl<T: UnorderedHash> Hash for Unordered<T>
impl<T: UnorderedHash> Hash for Unordered<T>
Auto Trait Implementations§
impl<T> Freeze for Unordered<T>
impl<T> RefUnwindSafe for Unordered<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Unordered<T>
impl<T> Sync for Unordered<T>
impl<T> Unpin for Unordered<T>
impl<T> UnsafeUnpin for Unordered<T>where
T: UnsafeUnpin + ?Sized,
impl<T> UnwindSafe for Unordered<T>where
T: UnwindSafe + ?Sized,
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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
Source§fn as_unordered(&self) -> &Unordered<T>
fn as_unordered(&self) -> &Unordered<T>
Views this value as an
Unordered reference.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if
self is equivalent to key.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.