'Use a type parameter in `as` expression inside a generic function

In the code below the type parameter T can only be an integer type.

fn foo<T>() {
    let _ = 0 as T;
}

How to restrict the T to make the function to compile?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source