matches!
macro matches(Expr ty, Expr expr) -> Code Import
Source: use tests::{matches}; src/tests.hy Returns whether expr matches the pattern ty, as a bool.
Expands to a match with one arm for the pattern and a default arm.
Invoke it as matches!(…); the arguments are passed as code (Expr), not values.
Parameters#
| Name | Type |
|---|---|
ty | Expr |
expr | Expr |
Returns#
Code
Examples#
use tests::{assert, matches};
let r: Result<int, string> = Result::Ok(3);
assert!(matches!(Result::Ok(_), r));
assert!(!matches!(Option::Some(_), Option::None));