There is JSON in which such value comes - 3h: 0.0175. The compiler swears at 3h:
src/main.rs:97:9: 97:11 error: expected identifier, found `3h` src/main.rs:97 pub 3h: f64, How to get around? Broke the brain .... here is the minimum code:
extern crate rest_client; extern crate rustc_serialize; use rest_client::RestClient; use rustc_serialize::json; use std::env; #[derive(RustcDecodable, RustcEncodable, Debug)] pub struct JsonListSnow { pub 3h: f64, //вот собственно.... } #[derive(RustcDecodable, RustcEncodable, Debug)] pub struct JsonList { pub snow: JsonListSnow, } #[derive(RustcDecodable, RustcEncodable, Debug)] pub struct Json { pub list: Vec<JsonList>, } fn main() { let s = "http://api.openweathermap.org/data/2.5/"; //вектор vr[] получает значения из разбора аргументов командной строки let req = s.to_string()+&vr[0]+"?q="+&vr[1]+"&units=metric&appid="+&vr[2]; let response = RestClient::get(&req).unwrap(); let decoded: Json = json::decode(&response.body).unwrap(); } JSON example:
{"city":{"id":2014624,"name":"Udachnyy","coord": {"lon":112.400002,"lat":66.416672},"country":"RU","population":0,"sys": {"population":0}},"cod":"200","message":0.1719,"cnt":35,"list": [{"dt":1475334000,"main":"temp":277.32,"temp_min":267.745,"temp_max": 277.32, "pressure":985.96,"sea_level":1039.29,"grnd_level":985.96, "humidity":89,"temp_kf":9.58},"weather": [{"id":600,"main":"Snow","description":"light snow","icon":"13n"}],"clouds":{"all":76},"wind": {"speed":1.51,"deg":333.501},"snow":{"3h":0.11},"sys": {"pod":"n"},"dt_txt":"2016-10-01 15:00:00"}