我想知道,有没有办法通过指定的属性使用他们的API查找维基数据实体.例如,有很多实体具有Freebase ID属性(属性:P646).它是唯一标识符,我希望通过此标识符获取实体.
谁知道如何实现这一目标?
我正在学习 Rust 的异步/等待功能,并坚持执行以下任务。我想:
浏览类似的问题我写了以下代码:
use tokio;
use std::pin::Pin;
use std::future::Future;
struct Services {
s1: Box<dyn FnOnce(&mut Vec<usize>) -> Pin<Box<dyn Future<Output = ()>>>>,
}
impl Services {
fn new(f: Box<dyn FnOnce(&mut Vec<usize>) -> Pin<Box<dyn Future<Output = ()>>>>) -> Self {
Services { s1: f }
}
}
enum NumberOperation {
AddOne,
MinusOne
}
#[tokio::main]
async fn main() {
let mut input = vec![1,2,3];
let op = NumberOperation::AddOne;
let s = Services::new(Box::new(|numbers: &mut Vec<usize>| Box::pin(async move {
for n …Run Code Online (Sandbox Code Playgroud)