Impl Display for {GPSValue, Coordinates}
This commit is contained in:
parent
a34a9239a7
commit
0efffdbea3
1 changed files with 15 additions and 0 deletions
|
@ -18,6 +18,9 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::fmt::Display;
|
||||||
|
use std::fmt::Formatter;
|
||||||
|
use std::fmt::Result as FmtResult;
|
||||||
|
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
|
@ -96,6 +99,12 @@ impl FromValue for GPSValue {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for GPSValue {
|
||||||
|
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||||
|
write!(f, "{}° {}\" {}'", self.degree, self.minutes, self.seconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Data-transfer type for transfering longitude-latitude-pairs
|
/// Data-transfer type for transfering longitude-latitude-pairs
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Coordinates {
|
pub struct Coordinates {
|
||||||
|
@ -145,6 +154,12 @@ impl FromValue for Coordinates {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Coordinates {
|
||||||
|
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||||
|
write!(f, "longitude = {}\nlatitude = {}", self.longitude, self.latitude)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Helper to convert a i64 to i8 or return an error if this doesn't work.
|
/// Helper to convert a i64 to i8 or return an error if this doesn't work.
|
||||||
fn i64_to_i8(i: i64) -> Result<i8> {
|
fn i64_to_i8(i: i64) -> Result<i8> {
|
||||||
if i > (<i8>::max_value() as i64) {
|
if i > (<i8>::max_value() as i64) {
|
||||||
|
|
Loading…
Reference in a new issue