Rust - в чем ошибка в match для клиента Postgresql?
Подскажите в чем ошибка или в каком направлении искать поиск причины? Почему получаются разные типы в данном случае?
let client = Client::connect("postgresql://user:pass@localhost:5432/base", NoTls).unwrap();
match client {
Ok(mut client) => {
let stmt = client.prepare("INSERT INTO status (status) VALUES ($1)").unwrap();
client
.execute(&stmt, &[&json_data])
.expect("Failed to execute statement");
println!("JSON data inserted successfully");
}
Err(err) => println!("Error: {}", err),
}
Выдает сообщение:
error[E0308]: mismatched types
--> src/main.rs:252:9
|
251 | match client {
| ------ this expression has type `postgres::Client`
252 | Ok(mut client) => {
| ^^^^^^^^^^^^^^ expected `Client`, found `Result<_, _>`
|
= note: expected struct `postgres::Client`
found enum `Result<_, _>`
Источник: Stack Overflow на русском