I'm trying to connect to a server using websockets. So once after the connection is established, I am trying to return that connection object. But I'm unable to find the correct return type for it.
In this I'm trying to return the "client" variable. Can someone please let me know about the return type for this?
If you make another variable of a type that you know and then try to put the unknown variable into the known variable type, the error message will tell you both types.
fn main() {
let mut x: i32 = 4; // We know x is i32
let y = "what is y";
x = y; // note error message will tell you type of both x and y
println!("{} {}", x, y);
}
Will give you this error telling you the unknown type of 'y'
error[E0308]: mismatched types
--> src/main.rs:4:9
|
2 | let mut x: i32 = 4; // We know x is i32
| --- expected due to this type
3 | let y = "what is y";
4 | x = y; // note error message will tell you type of both x and y
| ^ expected `i32`, found `&str`