Complete the code to define a function that returns the first element of a slice.
fn first_element(slice: &[[1]]) -> &[1] { &slice[0] }
Using T as a generic type allows the function to work with any type of slice.
Complete the code to declare a generic struct named Point.
struct Point<[1]> {
x: T,
y: T,
}The generic type T allows the struct to hold any type for its fields.
Fix the error in the function signature to make it generic.
fn print_value(value: [1]) { println!("{}", value); }
Using T as a generic type requires declaring it in the function signature with <T>.
Fill both blanks to define a generic function that returns the larger of two values.
fn max_value<[1]: PartialOrd>(a: [1], b: [1]) -> [1] { if a > b { a } else { b } }
: PartialOrd.The generic type T is used consistently and constrained by PartialOrd to allow comparison.
Fill all three blanks to implement a generic struct with two different types.
struct Pair<[1], [2]> { first: [1], second: [2], }
The struct uses two generic types T and U for its fields.
