我正在使用 Rust 和 Diesel:
fn create_asset_from_object(assets: &HashMap<String, Assets_Json>) {
let connection: PgConnection = establish_connection();
println!("==========================================================");
insert_Asset(&connection, &assets);
}
pub fn insert_Asset(conn: &PgConnection, assests: &HashMap<String, Assets_Json>){
use self::schema::assets;
for (currency, assetInfo) in assests {
let new_asset = self::models::NewAssets {
asset_name: ¤cy,
aclass: &assetInfo.aclass,
altname: &assetInfo.altname,
decimals: assetInfo.decimals,
display_decimals: assetInfo.display_decimals,
};
//let result = diesel::insert(&new_asset).into(assets::table).get_result(conn).expect("Error saving new post");
println!("result, {:#?}", diesel::insert(&new_asset).into(assets::table).get_result(conn).expect("Error saving new post"));
}
}
编译器错误:
error[E0282]: type annotations needed
--> src/persistence_service.rs:107:81
|
107 | println!("result, {:#?}", diesel::insert(&new_asset).into(assets::table).get_result(conn).expect("Error saving new post"));
| ^^^^^^^^^^ cannot infer type for `U`