#![no_std]
use core::str::FromStr;
pub struct WorldFile {
pub x_scale: f64,
pub y_skew: f64,
pub x_skew: f64,
pub y_scale: f64,
pub x_coord: f64,
pub y_coord: f64,
}
impl FromStr for WorldFile {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
let mut lines = s.lines();
let x_scale: f64 = match lines.next() {
Some(s) => match FromStr::from_str(s) {
Ok(i) => i,
Err(_) => return Err(()),
},
None => return Err(()),
};
let y_skew: f64 = match lines.next() {
Some(s) => match FromStr::from_str(s) {
Ok(i) => i,
Err(_) => return Err(()),
},
None => return Err(()),
};
let x_skew: f64 = match lines.next() {
Some(s) => match FromStr::from_str(s) {
Ok(i) => i,
Err(_) => return Err(()),
},
None => return Err(()),
};
let y_scale: f64 = match lines.next() {
Some(s) => match FromStr::from_str(s) {
Ok(i) => i,
Err(_) => return Err(()),
},
None => return Err(()),
};
let x_coord: f64 = match lines.next() {
Some(s) => match FromStr::from_str(s) {
Ok(i) => i,
Err(_) => return Err(()),
},
None => return Err(()),
};
let y_coord: f64 = match lines.next() {
Some(s) => match FromStr::from_str(s) {
Ok(i) => i,
Err(_) => return Err(()),
},
None => return Err(()),
};
Ok(WorldFile {
x_scale: x_scale,
y_skew: y_skew,
x_skew: x_skew,
y_scale: y_scale,
x_coord: x_coord,
y_coord: y_coord,
})
}
}