Function match_ty_with_ident

Source
pub fn match_ty_with_ident(
    tcx: TyCtxt<'_>,
    def_id: DefId,
    type_ident: String,
) -> Option<Ty<'_>>
Expand description

Match a type identifier string to a concrete Rust type

This function attempts to match a given type identifier (e.g., “u32”, “T”, “MyStruct”) to a type in the provided parameter type list. It handles:

  1. Built-in primitive types (u32, usize, etc.)
  2. Generic type parameters (T, U, etc.)
  3. User-defined types found in the parameter list

Arguments:

  • tcx: Type context for querying compiler information
  • type_ident: String representing the type identifier to match
  • param_ty: List of parameter types from the function signature

Returns:

  • Some(Ty) if a matching type is found
  • None if no match is found