【发布时间】:2021-10-09 08:05:04
【问题描述】:
我的问题是关于 rust 中的取消引用和引用。
我有以下代码:
#[database("pg_db")]
struct PgDbConn(diesel::PgConnection);
fn main() {
rocket::ignite()
.attach(PgDbConn::fairing())
.mount("/", routes![find_one, find_all])
.launch();
}
#[get("/<id>", format = "json")]
fn find_one(conn: PgDbConn, id: i32) -> Result<Json<Person>, NotFound<String>> {
let one: QueryResult<Person> = person.find(id).first(&*conn); // Notice here deref & ref
...
我想知道我的PgDbConn 结构是如何作为连接结束的。有人可以详细解释一下机制吗?
【问题讨论】:
标签: rust rust-diesel rocket