haystack_types/
h_coord.rs

1use num::Float;
2use crate::{HType, HVal, NumTrait};
3use std::fmt::{self,Display,Write};
4use core::str::FromStr;
5
6#[derive(PartialEq,Debug)]
7pub struct HCoord<T> {
8    lat: T,
9    long: T
10}
11
12pub type Coord<T> = HCoord<T>;
13
14const THIS_TYPE: HType = HType::Coord;
15
16impl <T>HCoord<T> {
17    pub fn new(lat: T, long: T) -> HCoord<T> {
18        HCoord { lat, long }
19    }
20}
21
22impl <'a,T: NumTrait + 'a>HVal<'a,T> for HCoord<T> {
23    fn to_zinc(&self, buf: &mut String) -> fmt::Result {
24        write!(buf,"C({},{})",self.lat,self.long)
25    }
26    fn to_json(&self, buf: &mut String) -> fmt::Result {
27        write!(buf,"c:{},{}",self.lat,self.long)
28    }
29    fn haystack_type(&self) -> HType { THIS_TYPE }
30
31    set_trait_eq_method!(get_coord_val,'a,T);
32    set_get_method!(get_coord_val, HCoord<T>);
33}