Complete the code to declare a generic function that returns the input value.
fn identity<T>(value: T) -> T {
return [1];
}The function returns the input parameter value directly.
Complete the code to call the generic function with an integer argument.
fn main() {
let result = identity::<[1]>(5);
println!("{}", result);
}f64 for an integer argument.String.The generic type parameter is specified as i32 to match the integer argument 5.
Fix the error in the generic function declaration by completing the missing syntax.
fn [1]<T>(x: T) -> T {
x
}main which is reserved for the program entry point.print.The function name identity matches the intended generic function.
Fill both blanks to define a generic function that swaps two values and returns a tuple.
fn swap<T>(a: T, b: T) -> ([1], [2]) { (b, a) }
i32 or String.The function returns a tuple of the same generic type T for both elements.
Fill all three blanks to complete a generic function that compares two values and returns the greater one.
fn max_value<T: PartialOrd>(a: T, b: T) -> [1] { if a [2] b { [3] } else { b } }
The function returns a value of type T. It compares a and b using the > operator and returns a if it is greater.