match_type

Function match_type 

Source
pub fn match_type<T: 'static, R>(
    value: &T,
    patterns: &[(Box<dyn TypePattern<T>>, Box<dyn Fn(&T) -> R>)],
) -> Option<R>
Expand description

Matches a value against a series of type patterns and handlers.

§Type Parameters

  • T - The type of the value to match
  • R - The return type of the pattern handlers

§Arguments

  • value - The value to match against patterns
  • patterns - A slice of tuples containing patterns and their handlers

§Returns

  • Some(R) if a pattern matches and its handler succeeds
  • None if no pattern matches