use tokenizer::{PeekableTokens, Token};
use FromTokens;
#[derive(Default)]
pub struct Coord {
pub x: f64,
pub y: f64,
pub z: Option<f64>,
pub m: Option<f64>,
}
impl FromTokens for Coord {
fn from_tokens(tokens: &mut PeekableTokens) -> Result<Self, &'static str> {
let x = match tokens.next() {
Some(Token::Number(n)) => n,
_ => return Err("Expected a number for the X coordinate"),
};
let y = match tokens.next() {
Some(Token::Number(n)) => n,
_ => return Err("Expected a number for the Y coordinate"),
};
Ok(Coord {
x: x,
y: y,
z: None,
m: None,
})
}
}