@@ -534,7 +534,7 @@ impl Version {
534534 if value. is_empty ( ) {
535535 self . without_local ( )
536536 } else {
537- self . make_full ( ) . local = LocalVersion :: Actual ( value) ;
537+ self . make_full ( ) . local = LocalVersion :: Segments ( value) ;
538538 self
539539 }
540540 }
@@ -544,7 +544,7 @@ impl Version {
544544 #[ must_use]
545545 pub fn with_local ( mut self , value : LocalVersion ) -> Self {
546546 match value {
547- LocalVersion :: Actual ( segments) => self . with_local_segments ( segments) ,
547+ LocalVersion :: Segments ( segments) => self . with_local_segments ( segments) ,
548548 LocalVersion :: Max => {
549549 self . make_full ( ) . local = value;
550550 self
@@ -628,7 +628,7 @@ impl Version {
628628 pre : small. pre ( ) ,
629629 post : small. post ( ) ,
630630 dev : small. dev ( ) ,
631- local : LocalVersion :: Actual ( vec ! [ ] ) ,
631+ local : LocalVersion :: Segments ( vec ! [ ] ) ,
632632 } ;
633633 * self = Self {
634634 inner : Arc :: new ( VersionInner :: Full { full } ) ,
@@ -726,10 +726,10 @@ impl std::fmt::Display for Version {
726726 String :: new ( )
727727 } else {
728728 match self . local ( ) {
729- LocalVersionSlice :: Actual ( _) => {
730- format ! ( "+{}" , self . local( ) . local_identifier_string ( ) )
729+ LocalVersionSlice :: Segments ( _) => {
730+ format ! ( "+{}" , self . local( ) )
731731 }
732- LocalVersionSlice :: Sentinel => String :: new ( ) ,
732+ LocalVersionSlice :: Max => String :: new ( ) ,
733733 }
734734 } ;
735735 write ! ( f, "{epoch}{release}{pre}{post}{dev}{local}" )
@@ -849,7 +849,7 @@ impl FromStr for Version {
849849/// `min, .devN, aN, bN, rcN, <no suffix>, .postN, max`.
850850/// Its representation is thus:
851851/// * The most significant 3 bits of Byte 2 corresponds to a value in
852- /// the range 0-6 inclusive, corresponding to min, dev, pre-a, pre-b, pre-rc,
852+ /// the range 0-7 inclusive, corresponding to min, dev, pre-a, pre-b, pre-rc,
853853/// no-suffix or post releases, respectively. `min` is a special version that
854854/// does not exist in PEP 440, but is used here to represent the smallest
855855/// possible version, preceding any `dev`, `pre`, `post` or releases. `max` is
@@ -1178,7 +1178,7 @@ impl VersionSmall {
11781178 fn local ( & self ) -> LocalVersionSlice {
11791179 // A "small" version is never used if the version has a non-zero number
11801180 // of local segments.
1181- LocalVersionSlice :: Actual ( & [ ] )
1181+ LocalVersionSlice :: Segments ( & [ ] )
11821182 }
11831183
11841184 #[ inline]
@@ -1200,13 +1200,13 @@ impl VersionSmall {
12001200
12011201 #[ inline]
12021202 fn suffix_version ( & self ) -> u64 {
1203- self . repr & 0x001F_FFFF
1203+ self . repr & Self :: SUFFIX_MAX_VERSION
12041204 }
12051205
12061206 #[ inline]
12071207 fn set_suffix_version ( & mut self , value : u64 ) {
1208- debug_assert ! ( value <= 0x001F_FFFF ) ;
1209- self . repr &= !0x001F_FFFF ;
1208+ debug_assert ! ( value <= Self :: SUFFIX_MAX_VERSION ) ;
1209+ self . repr &= !Self :: SUFFIX_MAX_VERSION ;
12101210 self . repr |= value;
12111211 }
12121212}
@@ -1404,51 +1404,55 @@ impl std::fmt::Display for Prerelease {
14041404#[ cfg_attr( feature = "rkyv" , rkyv( derive( Debug , Eq , PartialEq , PartialOrd , Ord ) ) ) ]
14051405pub enum LocalVersion {
14061406 /// A sequence of local segments.
1407- Actual ( Vec < LocalSegment > ) ,
1407+ Segments ( Vec < LocalSegment > ) ,
14081408 /// An internal-only value that compares greater to all other local versions.
14091409 Max ,
14101410}
14111411
14121412/// Like [`LocalVersion`], but using a slice
14131413#[ derive( Eq , PartialEq , Debug , Clone , Hash ) ]
14141414pub enum LocalVersionSlice < ' a > {
1415- /// Like [`LocalVersion::Actual `]
1416- Actual ( & ' a [ LocalSegment ] ) ,
1415+ /// Like [`LocalVersion::Segments `]
1416+ Segments ( & ' a [ LocalSegment ] ) ,
14171417 /// Like [`LocalVersion::Sentinel`]
1418- Sentinel ,
1418+ Max ,
14191419}
14201420
14211421impl LocalVersion {
14221422 /// Convert the local version segments into a slice.
14231423 pub fn as_slice ( & self ) -> LocalVersionSlice < ' _ > {
14241424 match self {
1425- LocalVersion :: Actual ( segments) => LocalVersionSlice :: Actual ( segments) ,
1426- LocalVersion :: Max => LocalVersionSlice :: Sentinel ,
1425+ LocalVersion :: Segments ( segments) => LocalVersionSlice :: Segments ( segments) ,
1426+ LocalVersion :: Max => LocalVersionSlice :: Max ,
14271427 }
14281428 }
14291429
14301430 /// Clear the local version segments, if they exist.
14311431 pub fn clear ( & mut self ) {
14321432 match self {
1433- Self :: Actual ( segments) => segments. clear ( ) ,
1434- Self :: Max => * self = Self :: Actual ( Vec :: new ( ) ) ,
1433+ Self :: Segments ( segments) => segments. clear ( ) ,
1434+ Self :: Max => * self = Self :: Segments ( Vec :: new ( ) ) ,
14351435 }
14361436 }
14371437}
14381438
1439- impl LocalVersionSlice < ' _ > {
1440- /// Output the local version identifier string.
1441- ///
1442- /// [`LocalVersionSlice::Sentinel`] maps to `"[max]"` which is otherwise an illegal local
1443- /// version because `[` and `]` are not allowed.
1444- pub fn local_identifier_string ( & self ) -> String {
1439+ /// Output the local version identifier string.
1440+ ///
1441+ /// [`LocalVersionSlice::Max`] maps to `"[max]"` which is otherwise an illegal local
1442+ /// version because `[` and `]` are not allowed.
1443+ impl std :: fmt :: Display for LocalVersionSlice < ' _ > {
1444+ fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
14451445 match self {
1446- LocalVersionSlice :: Actual ( segments) => segments
1447- . iter ( )
1448- . map ( ToString :: to_string)
1449- . collect :: < Vec < String > > ( )
1450- . join ( "." ) ,
1451- LocalVersionSlice :: Sentinel => String :: from ( "[max]" ) ,
1446+ LocalVersionSlice :: Segments ( segments) => {
1447+ for ( i, segment) in segments. iter ( ) . enumerate ( ) {
1448+ if i > 0 {
1449+ write ! ( f, "." ) ?;
1450+ }
1451+ write ! ( f, "{segment}" ) ?;
1452+ }
1453+ Ok ( ( ) )
1454+ }
1455+ LocalVersionSlice :: Max => write ! ( f, "[max]" ) ,
14521456 }
14531457 }
14541458}
@@ -1462,18 +1466,18 @@ impl PartialOrd for LocalVersionSlice<'_> {
14621466impl Ord for LocalVersionSlice < ' _ > {
14631467 fn cmp ( & self , other : & Self ) -> Ordering {
14641468 match ( self , other) {
1465- ( LocalVersionSlice :: Actual ( lv1) , LocalVersionSlice :: Actual ( lv2) ) => lv1. cmp ( lv2) ,
1466- ( LocalVersionSlice :: Actual ( _) , LocalVersionSlice :: Sentinel ) => Ordering :: Less ,
1467- ( LocalVersionSlice :: Sentinel , LocalVersionSlice :: Actual ( _) ) => Ordering :: Greater ,
1468- ( LocalVersionSlice :: Sentinel , LocalVersionSlice :: Sentinel ) => Ordering :: Equal ,
1469+ ( LocalVersionSlice :: Segments ( lv1) , LocalVersionSlice :: Segments ( lv2) ) => lv1. cmp ( lv2) ,
1470+ ( LocalVersionSlice :: Segments ( _) , LocalVersionSlice :: Max ) => Ordering :: Less ,
1471+ ( LocalVersionSlice :: Max , LocalVersionSlice :: Segments ( _) ) => Ordering :: Greater ,
1472+ ( LocalVersionSlice :: Max , LocalVersionSlice :: Max ) => Ordering :: Equal ,
14691473 }
14701474 }
14711475}
14721476
14731477impl LocalVersionSlice < ' _ > {
14741478 /// Whether the local version is absent
14751479 pub fn is_empty ( & self ) -> bool {
1476- matches ! ( self , Self :: Actual ( & [ ] ) )
1480+ matches ! ( self , Self :: Segments ( & [ ] ) )
14771481 }
14781482}
14791483
@@ -1924,7 +1928,7 @@ impl<'a> Parser<'a> {
19241928 . with_pre ( self . pre )
19251929 . with_post ( self . post )
19261930 . with_dev ( self . dev )
1927- . with_local ( LocalVersion :: Actual ( self . local ) ) ;
1931+ . with_local ( LocalVersion :: Segments ( self . local ) ) ;
19281932 VersionPattern {
19291933 version,
19301934 wildcard : self . wildcard ,
0 commit comments