Skip to main content

test_type

Function test_type 

Source
pub fn test_type<F>(
    types: &dyn TypeDatabase,
    type_id: TypeId,
    predicate: F,
) -> bool
where F: Fn(&TypeData) -> bool,
Expand description

Test a type against a predicate function.

§Example

use crate::{TypeData, LiteralValue, visitor::test_type};

let is_string_literal = test_type(&types, type_id, |key| {
    matches!(key, TypeData::Literal(LiteralValue::String(_)))
});