pub struct ShapeMismatch {
pub expected: Shape,
pub received: Shape,
pub path: Vec<NamedShapePathKey>,
}
Expand description
The Shape::validate*
methods return a vector of ShapeMismatch
errors
that is non-empty when validation fails.
Each ShapeMismatch
error contains the expected
shape, the received
shape, and a path
of NamedShapePathKey
elements that leads from the root
shape to the nested object/array location where the mismatch happened.
Conveniently, the expected
/received
terminology works for both the
expected.accepts(received)
and received.satisfies(expected)
directions
of comparison, so it doesn’t matter that ShapeMismatch
errors happen to be
generated by the internal satisfies_at_path
method rather than by the
validate
method (which would also work).
Once issue #5 is implemented, you’ll be able to obtain source location
information from the expected
and received
shapes (instead of adding
additional fields to the ShapeMismatch
struct).
Fields§
§expected: Shape
§received: Shape
§path: Vec<NamedShapePathKey>
Trait Implementations§
Source§impl Clone for ShapeMismatch
impl Clone for ShapeMismatch
Source§fn clone(&self) -> ShapeMismatch
fn clone(&self) -> ShapeMismatch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ShapeMismatch
impl Debug for ShapeMismatch
Source§impl Hash for ShapeMismatch
impl Hash for ShapeMismatch
Source§impl PartialEq for ShapeMismatch
impl PartialEq for ShapeMismatch
impl Eq for ShapeMismatch
impl StructuralPartialEq for ShapeMismatch
Auto Trait Implementations§
impl Freeze for ShapeMismatch
impl RefUnwindSafe for ShapeMismatch
impl Send for ShapeMismatch
impl Sync for ShapeMismatch
impl Unpin for ShapeMismatch
impl UnwindSafe for ShapeMismatch
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.