MCPcopy Create free account
hub / github.com/carllerche/assert-struct / expand_simple_assertion

Function expand_simple_assertion

assert-struct-macros/src/expand.rs:532–547  ·  view source on GitHub ↗

Generate simple assertion with error collection

(actual: &TokenStream, pattern: &PatternSimple)

Source from the content-addressed store, hash-verified

530
531/// Generate simple assertion with error collection
532fn expand_simple_assertion(actual: &TokenStream, pattern: &PatternSimple) -> TokenStream {
533 let expected = &pattern.expr;
534 let span = expected.span();
535 let error_push = generate_error_push(
536 span,
537 quote!(format!("{:?}", #actual)),
538 quote!(None),
539 pattern.node_id,
540 );
541
542 quote_spanned! {span=>
543 if !matches!(#actual, #expected) {
544 #error_push
545 }
546 }
547}
548
549/// Generate slice assertion with error collection
550fn expand_slice_assertion(value_expr: &TokenStream, pattern: &PatternSlice) -> TokenStream {

Callers 1

expand_pattern_assertionFunction · 0.85

Calls 2

generate_error_pushFunction · 0.85
spanMethod · 0.45

Tested by

no test coverage detected