@@ -468,48 +468,30 @@ impl SourceId {
468468
469469 /// Creates a new `SourceId` from this source with the given `precise`.
470470 pub fn with_git_precise ( self , fragment : Option < String > ) -> SourceId {
471- let precise = fragment. map ( |f| Precise :: GitUrlFragment ( f) ) ;
472- if self . inner . precise == precise {
473- self
474- } else {
475- SourceId :: wrap ( SourceIdInner {
476- precise,
477- ..( * self . inner ) . clone ( )
478- } )
479- }
471+ self . with_precise ( & fragment. map ( |f| Precise :: GitUrlFragment ( f) ) )
480472 }
481473
482474 /// Creates a new `SourceId` from this source without a `precise`.
483475 pub fn without_precise ( self ) -> SourceId {
484- if self . inner . precise . is_none ( ) {
485- self
486- } else {
487- SourceId :: wrap ( SourceIdInner {
488- precise : None ,
489- ..( * self . inner ) . clone ( )
490- } )
491- }
476+ self . with_precise ( & None )
492477 }
493478
494479 /// Creates a new `SourceId` from this source without a `precise`.
495480 pub fn with_locked_precise ( self ) -> SourceId {
496- if self . inner . precise == Some ( Precise :: Locked ) {
497- self
498- } else {
499- SourceId :: wrap ( SourceIdInner {
500- precise : Some ( Precise :: Locked ) ,
501- ..( * self . inner ) . clone ( )
502- } )
503- }
481+ self . with_precise ( & Some ( Precise :: Locked ) )
504482 }
505483
506484 /// Creates a new `SourceId` from this source with the `precise` from some other `SourceId`.
507485 pub fn with_precise_from ( self , v : Self ) -> SourceId {
508- if self . inner . precise == v. inner . precise {
486+ self . with_precise ( & v. inner . precise )
487+ }
488+
489+ fn with_precise ( self , precise : & Option < Precise > ) -> SourceId {
490+ if & self . inner . precise == precise {
509491 self
510492 } else {
511493 SourceId :: wrap ( SourceIdInner {
512- precise : v . inner . precise . clone ( ) ,
494+ precise : precise. clone ( ) ,
513495 ..( * self . inner ) . clone ( )
514496 } )
515497 }
0 commit comments