Macro in tests coil-stdlib

matches!

macro matches(Expr ty, Expr expr) -> Code
Import
use tests::{matches};
Source: 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#

NameType
tyExpr
exprExpr

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));

See also#

  • bool
  • not!: Expands to !expression.
  • eq!: Expands to lhs == rhs.
  • type!: Expands to typeof ty: the type of an expression, as a value that can be compared.
  • and!: Expands to lhs && rhs.
  • assert!: Fails the enclosing function with an error when condition is false.
↑ ↓ navigate ↵ open