@@ -55,30 +55,30 @@ impl Lookup {
5555 default_platform : Option < & PlatformSpec > ,
5656 version : & Version ,
5757 ) -> Source {
58- let default_or_none = default_platform
59- . and_then ( self . version_from_spec ( ) )
60- . and_then ( | ref default_version| {
61- if default_version == version {
62- Some ( Source :: Default )
63- } else {
64- None
65- }
66- } ) ;
67-
68- match project {
69- Some ( project ) => project
70- . platform ( )
71- . and_then ( self . version_from_spec ( ) )
72- . and_then ( |project_version| {
73- if & project_version == version {
74- Some ( Source :: Project ( project . manifest_file ( ) . to_owned ( ) ) )
75- } else {
76- default_or_none
77- }
78- } ) ,
79- None => default_or_none ,
80- }
81- . unwrap_or ( Source :: None )
58+ project
59+ . and_then ( |proj| {
60+ proj . platform ( )
61+ . and_then ( self . version_from_spec ( ) )
62+ . and_then ( |project_version| {
63+ if & project_version == version {
64+ Some ( Source :: Project ( proj . manifest_file ( ) . to_owned ( ) ) )
65+ } else {
66+ None
67+ }
68+ } )
69+ } )
70+ . or_else ( || {
71+ default_platform
72+ . and_then ( self . version_from_spec ( ) )
73+ . and_then ( |default_version| {
74+ if & default_version == version {
75+ Some ( Source :: Default )
76+ } else {
77+ None
78+ }
79+ } )
80+ } )
81+ . unwrap_or ( Source :: None )
8282 }
8383
8484 /// Determine the `Source` for a given kind of tool (`Lookup`).
@@ -87,16 +87,17 @@ impl Lookup {
8787 project : Option < & Project > ,
8888 default : Option < & PlatformSpec > ,
8989 ) -> Option < ( Source , Version ) > {
90- match project {
91- Some ( project) => project
92- . platform ( )
93- . and_then ( self . version_from_spec ( ) )
94- . map ( |version| ( Source :: Project ( project. manifest_file ( ) . to_owned ( ) ) , version) ) ,
95- None => default
96- . clone ( )
97- . and_then ( self . version_from_spec ( ) )
98- . map ( |version| ( Source :: Default , version) ) ,
99- }
90+ project
91+ . and_then ( |proj| {
92+ proj. platform ( )
93+ . and_then ( self . version_from_spec ( ) )
94+ . map ( |version| ( Source :: Project ( proj. manifest_file ( ) . to_owned ( ) ) , version) )
95+ } )
96+ . or_else ( || {
97+ default
98+ . and_then ( self . version_from_spec ( ) )
99+ . map ( |version| ( Source :: Default , version) )
100+ } )
100101 }
101102}
102103
0 commit comments