Function: cl-struct--pcase-macroexpander
cl-struct--pcase-macroexpander is a function defined in cl-macs.el.gz.
Signature
(cl-struct--pcase-macroexpander TYPE &rest FIELDS)
Documentation
Pcase patterns that match cl-struct EXPVAL of type TYPE.
Elements of FIELDS can be of the form (NAME PAT) in which case the contents of field NAME is matched against PAT, or they can be of the form NAME which is a shorthand for (NAME NAME).
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;; Closure converted to defun by helpful.
(defun cl-struct--pcase-macroexpander
(type &rest fields)
"Pcase patterns that match cl-struct EXPVAL of type TYPE.\nElements of FIELDS can be of the form (NAME PAT) in which case the\ncontents of field NAME is matched against PAT, or they can be of\nthe form NAME which is a shorthand for (NAME NAME)."
`(and
(pred
(pcase--flip cl-typep ',type))
,@(mapcar
(lambda
(field)
(let*
((name
(if
(consp field)
(car field)
field))
(pat
(if
(consp field)
(cadr field)
field)))
`(app ,(if
(eq
(cl-struct-sequence-type type)
'list)
`(nth ,(cl-struct-slot-offset type name))
`(pcase--flip aref ,(cl-struct-slot-offset type name)))
,pat)))
fields)))