Hi,
im trying to increment a tuple struct field by 2 as below with impl method on tuple struct.
struct Foo(i32);
impl Foo{
fn plus2(v: &Foo) -> Foo {
return Foo(*v.0 + 2);
}
}
fn main()
{
let x = Foo(2);
let y = Foo::plus2(&x);
println!( "{} {}" , x.0, y.0);
}
It throws the following error:
error[E0614]****: type `i32` cannot be dereferenced**
tuple_struct.rs:8:10
return Foo(*v.0 + 2);
**|******. **^^^^**
What am I doing wrong? I am assuming *v would dereference the tuple reference and then .0 would access the 0th field.