I've applied generics to a struct and want to get its output in an Option<_, _>
type using a getter method implemented on the struct.
struct Point<T, U> {
x: T,
y: U,
}
impl<T, U> Point<T, U> {
fn x(&self) -> Option<T, U> {
let z = &self.x;
z.get(5);
}
}
fn main() {
let p = Point { x: 5, y: 10.0 };
println!("p.x = {}", p.x());
}
The output of the above mentioned code is
error[E0107]: wrong number of type arguments: expected 1, found 2
--> src/main.rs:6:30
|
6 | fn x(&self) -> Option<T, U> {
| ^ unexpected type argument