diff --git a/src/_macros.rs b/src/_macros.rs index f663e7fd0..e9db58982 100644 --- a/src/_macros.rs +++ b/src/_macros.rs @@ -368,7 +368,7 @@ macro_rules! impl_f64_newtypes { ($type: ty) => { impl std::fmt::Display for $type { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "{}({})", stringify!($idtype), self.0) + write!(f, "{}({})", stringify!($type), self.0) } } diff --git a/src/lib.rs b/src/lib.rs index 03010cb2a..01d2a0fc0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -486,11 +486,33 @@ pub fn c_api_version() -> String { #[cfg(test)] mod tests { use super::c_api_version; + use super::Location; + use super::Position; + use super::Time; #[test] fn test_c_api_version() { let _ = c_api_version(); } + + #[test] + fn test_f64_newtype_Display() { + let x = Position::from(1.0); + let mut output = String::new(); + std::fmt::write(&mut output, format_args!("{}", x)) + .expect("Error occurred while trying to write in String"); + assert_eq!(output, "Position(1)".to_string()); + let x = Time::from(1.0); + let mut output = String::new(); + std::fmt::write(&mut output, format_args!("{}", x)) + .expect("Error occurred while trying to write in String"); + assert_eq!(output, "Time(1)".to_string()); + let x = Location::from(1.0); + let mut output = String::new(); + std::fmt::write(&mut output, format_args!("{}", x)) + .expect("Error occurred while trying to write in String"); + assert_eq!(output, "Location(1)".to_string()); + } } // Testing modules diff --git a/src/prelude.rs b/src/prelude.rs index 74d9543fe..16159a826 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -8,6 +8,7 @@ pub use crate::TSK_NODE_IS_SAMPLE; pub use streaming_iterator::DoubleEndedStreamingIterator; pub use streaming_iterator::StreamingIterator; pub use { - crate::EdgeId, crate::IndividualId, crate::MigrationId, crate::MutationId, crate::NodeId, - crate::PopulationId, crate::SiteId, crate::SizeType, + crate::EdgeId, crate::IndividualId, crate::Location, crate::MigrationId, crate::MutationId, + crate::NodeId, crate::PopulationId, crate::Position, crate::SiteId, crate::SizeType, + crate::Time, };