use std::str::FromStr; use wasm_bindgen::prelude::*; // #[wasm_bindgen] // extern "C" { // #[wasm_bindgen(js_namespace = console, js_name = log)] // fn log_str(s: &str); // } #[wasm_bindgen] pub fn address_from_lat_lon(lat: f64, lon: f64) -> Result { xpin::Address::from_lat_lon(lat, lon) .map(|a| a.to_string()) .map_err(|e| e.to_string()) } #[wasm_bindgen] pub fn address_to_lat_lon(addr_str: &str) -> Result, String> { xpin::Address::from_str(addr_str) .as_ref() .map_err(|e| e.to_string()) .map(xpin::Address::as_lat_lon) .map(|(lat, lon)| vec![lat, lon]) }