pub struct ShapeMatch {
pub accepted: bool,
pub captures: ShapeBindings,
pub score: MatchScore,
pub diagnostics: Vec<Diagnostic>,
}Expand description
The outcome of checking a value or expr against a Shape.
Carries acceptance, captured ShapeBindings, a MatchScore for
ranking, and any Diagnostics gathered during the check.
§Examples
use sim_kernel::shape::{MatchScore, ShapeMatch};
let ok = ShapeMatch::accept(MatchScore::exact(3));
assert!(ok.accepted);
assert_eq!(ok.score.value(), 3);
let no = ShapeMatch::reject("expected a string");
assert!(!no.accepted);
assert_eq!(no.diagnostics.len(), 1);Fields§
§accepted: boolWhether the input satisfied the shape.
captures: ShapeBindingsNames captured by the match.
score: MatchScoreRanking score for overload selection.
diagnostics: Vec<Diagnostic>Diagnostics gathered while matching.
Implementations§
Source§impl ShapeMatch
impl ShapeMatch
Sourcepub fn accept(score: MatchScore) -> Self
pub fn accept(score: MatchScore) -> Self
An accepted match with the given score and no captures or diagnostics.
Sourcepub fn reject(message: impl Into<String>) -> Self
pub fn reject(message: impl Into<String>) -> Self
A rejected match carrying a single error diagnostic.
Sourcepub fn reject_with_diagnostic(diagnostic: Diagnostic) -> Self
pub fn reject_with_diagnostic(diagnostic: Diagnostic) -> Self
A rejected match carrying one already-built diagnostic.
Trait Implementations§
Source§impl Clone for ShapeMatch
impl Clone for ShapeMatch
Source§fn clone(&self) -> ShapeMatch
fn clone(&self) -> ShapeMatch
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ShapeMatch
impl !UnwindSafe for ShapeMatch
impl Freeze for ShapeMatch
impl Send for ShapeMatch
impl Sync for ShapeMatch
impl Unpin for ShapeMatch
impl UnsafeUnpin for ShapeMatch
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