summaryrefslogtreecommitdiffstats
path: root/src/pkgver/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkgver/mod.rs')
-rw-r--r--src/pkgver/mod.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/pkgver/mod.rs b/src/pkgver/mod.rs
index cc00877..c97b4a2 100644
--- a/src/pkgver/mod.rs
+++ b/src/pkgver/mod.rs
@@ -21,13 +21,30 @@ fn split_full_version(v: &str) -> (String, String, String) {
}
}
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct Version {
- pub epoch: String,
- pub pkgver: String,
- pub pkgrel: String,
+/// The real definition. The module is private, so this `pub`
+/// is not a nameable path from outside; the alias below is the
+/// only way to reach it, and the alias is what carries the
+/// feature-conditional visibility.
+mod version {
+ #[derive(Debug, Clone, PartialEq, Eq)]
+ pub struct Version {
+ pub epoch: String,
+ pub pkgver: String,
+ pub pkgrel: String,
+ }
}
+/// a parsed epoch-ver-rel. Every caller uses the value `parse` hands back without naming the type; the tests that pin the ordering do name it.
+///
+/// `pub` only under `test-support`. Production reaches the type
+/// through its own module and never names it from outside; the
+/// outside reader that needs the name is a test.
+#[cfg(feature = "test-support")]
+pub use version::Version;
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) use version::Version;
+
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", full_version(&self.epoch, &self.pkgver, &self.pkgrel))
@@ -45,9 +62,6 @@ impl Version {
fn epoch_as_i64(&self) -> i64 {
self.epoch.trim().parse().unwrap_or(0)
}
- pub fn display(&self) -> String {
- self.to_string()
- }
}
pub fn compare(