Nitpick Generics

Nitpick supports zero-cost generic programming via monomorphization. Generic type parameters are declared using <T> syntax.

1. Generic Functions and Structs

You can define functions and data structures that operate over generic types.

// Generic Struct
struct:Container<T> = {
    T:value;
};

// Generic Function
func:extract_value<T> = T(Container<T>:c) {
    pass c.value;
};

2. Turbofish Instantiation (::<T>)

When the compiler cannot infer the type of a generic parameter from context, you must explicitly provide the type using the turbofish operator ::<T>.

int32:val = extract_value::<int32>(my_container) ? 0i32;

3. The Type Keyword

The Type keyword is used in advanced generic constraints (often in conjunction with Type checking or existential configurations).

// Ensures T strictly conforms to an expected Type layout
// (Often used in bounds checking and trait bounds)