From 1b76d8a29266bca27796a424b3156484df514517 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 4 Feb 2022 13:52:27 -0800 Subject: [PATCH] Make the [src] link on impl Default for VersionReq more comprehensible --- src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4de1bfba..b698fca9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,7 +184,8 @@ pub struct Version { /// - Whitespace is permitted around commas and around operators. Whitespace is /// not permitted within a partial version, i.e. anywhere between the major /// version number and its minor, patch, pre-release, or build metadata. -#[derive(Default, Clone, Eq, PartialEq, Hash, Debug)] +#[derive(Clone, Eq, PartialEq, Hash, Debug)] +#[cfg_attr(no_const_vec_new, derive(Default))] pub struct VersionReq { pub comparators: Vec, } @@ -477,6 +478,14 @@ impl VersionReq { } } +/// The default VersionReq is the same as [`VersionReq::STAR`]. +#[cfg(not(no_const_vec_new))] +impl Default for VersionReq { + fn default() -> Self { + VersionReq::STAR + } +} + impl Comparator { pub fn parse(text: &str) -> Result { Comparator::from_str(text)