小编lud*_*eed的帖子

JSON 响应的反序列化在字符串中保留引号

我正在使用 reqwest 查询 Google API:

let request_url = format!(
    "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=*\
     &inputtype=textquery\
     &fields=formatted_address,name,place_id,types\
     &locationbias=circle:50@{},{}\
     &key=my-secret-key",
    lat, lng
);

let mut response = reqwest::get(&request_url).expect("pffff");

let gr: GoogleResponse = response.json::<GoogleResponse>().expect("geeez");
Run Code Online (Sandbox Code Playgroud)

GoogleResponse结构体定义为

#[derive(Debug, Serialize, Deserialize)]
pub struct DebugLog {
    pub line: Vec<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Candidate {
    pub formatted_address: String,
    pub name: String,
    pub place_id: String,
    pub types: Vec<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GoogleResponse {
    pub candidates: Vec<Candidate>,
    pub debug_log: DebugLog,
    pub status: String,
}
Run Code Online (Sandbox Code Playgroud)

这一切都会编译,我可以发出请求,但是我在字段中得到的结果String …

serialization json rust serde rust-rocket

7
推荐指数
1
解决办法
3858
查看次数

如何使用 SQL 函数和用户提供的输入创建自定义 Diesel 查询?

我想执行一个使用 PostGIS 包的自定义 SQL 函数的查询。例如,我可以使用 psql 运行后续查询:

SELECT * FROM places 
WHERE earth_box(ll_to_earth(40.6333125,-8.659492), 20)
@> ll_to_earth(places.lat, places.lng);
Run Code Online (Sandbox Code Playgroud)

ll_to_earthearth_box是 PostGIS 函数。我怎样才能让这个查询与柴油与这些值latlng作为输入?

我浏览了文档,但我无法理解它。

sql rust rust-diesel

3
推荐指数
1
解决办法
1319
查看次数

Rust如何处理终止线程?

产生的线程之间是否存在父子连接?如果我从产生其他线程的位置杀死该线程,那些线程也将被杀死吗?这个操作系统是特定的吗?

concurrency multithreading rust

2
推荐指数
1
解决办法
447
查看次数