From 0efffdbea3aab44015ed7dedc78594ee80829ffa Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Sep 2017 17:23:46 +0200 Subject: [PATCH] Impl Display for {GPSValue, Coordinates} --- lib/entry/libimagentrygps/src/types.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/entry/libimagentrygps/src/types.rs b/lib/entry/libimagentrygps/src/types.rs index 587b17b4..54a60cbf 100644 --- a/lib/entry/libimagentrygps/src/types.rs +++ b/lib/entry/libimagentrygps/src/types.rs @@ -18,6 +18,9 @@ // use std::collections::BTreeMap; +use std::fmt::Display; +use std::fmt::Formatter; +use std::fmt::Result as FmtResult; 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 #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] 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. fn i64_to_i8(i: i64) -> Result { if i > (::max_value() as i64) {