36
36
//! extern crate pkg_config;
37
37
//!
38
38
//! fn main() {
39
- //! pkg_config::find_library ("foo").unwrap();
39
+ //! pkg_config::probe_library ("foo").unwrap();
40
40
//! }
41
41
//! ```
42
42
//!
46
46
//! extern crate pkg_config;
47
47
//!
48
48
//! fn main() {
49
- //! pkg_config::Config::new().statik(true).find ("foo").unwrap();
49
+ //! pkg_config::Config::new().statik(true).probe ("foo").unwrap();
50
50
//! }
51
51
//! ```
52
52
@@ -100,35 +100,38 @@ pub enum Error {
100
100
///
101
101
/// Contains the name of the responsible environment variable.
102
102
EnvNoPkgConfig ( String ) ,
103
+
103
104
/// Cross compilation detected.
104
105
///
105
106
/// Override with `PKG_CONFIG_ALLOW_CROSS=1`.
106
107
CrossCompilation ,
108
+
107
109
/// Failed to run `pkg-config`.
108
110
///
109
111
/// Contains the command and the cause.
110
112
Command { command : String , cause : io:: Error } ,
113
+
111
114
/// `pkg-config` did not exit sucessfully.
112
115
///
113
116
/// Contains the command and output.
114
117
Failure { command : String , output : Output } ,
118
+
115
119
#[ doc( hidden) ]
116
120
// please don't match on this, we're likely to add more variants over time
117
121
__Nonexhaustive,
118
122
}
119
123
120
124
impl error:: Error for Error {
121
125
fn description ( & self ) -> & str {
122
- use self :: Error :: * ;
123
126
match * self {
124
- EnvNoPkgConfig ( _) => "pkg-config requested to be aborted" ,
125
- CrossCompilation => {
127
+ Error :: EnvNoPkgConfig ( _) => "pkg-config requested to be aborted" ,
128
+ Error :: CrossCompilation => {
126
129
"pkg-config doesn't handle cross compilation. \
127
130
Use PKG_CONFIG_ALLOW_CROSS=1 to override"
128
131
}
129
- Command { .. } => "failed to run pkg-config" ,
130
- Failure { .. } => "pkg-config did not exit sucessfully" ,
131
- __Nonexhaustive => unreachable ! ( ) ,
132
+ Error :: Command { .. } => "failed to run pkg-config" ,
133
+ Error :: Failure { .. } => "pkg-config did not exit sucessfully" ,
134
+ Error :: __Nonexhaustive => panic ! ( ) ,
132
135
}
133
136
}
134
137
@@ -159,56 +162,54 @@ impl<'a> fmt::Debug for OutputDebugger<'a> {
159
162
} ;
160
163
161
164
fmt. debug_struct ( "Output" )
162
- . field ( "status" , & self . 0 . status )
163
- . field ( "stdout" , stdout_debug)
164
- . field ( "stderr" , stderr_debug)
165
- . finish ( )
165
+ . field ( "status" , & self . 0 . status )
166
+ . field ( "stdout" , stdout_debug)
167
+ . field ( "stderr" , stderr_debug)
168
+ . finish ( )
166
169
}
167
170
}
168
171
169
172
// Workaround for temporary lack of impl Debug for Output in stable std, continued
170
173
impl fmt:: Debug for Error {
171
174
fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
172
- use self :: Error :: * ;
173
175
match * self {
174
- EnvNoPkgConfig ( ref name) => {
176
+ Error :: EnvNoPkgConfig ( ref name) => {
175
177
f. debug_tuple ( "EnvNoPkgConfig" )
176
- . field ( name)
177
- . finish ( )
178
+ . field ( name)
179
+ . finish ( )
178
180
}
179
- CrossCompilation => write ! ( f, "CrossCompilation" ) ,
180
- Command { ref command, ref cause } => {
181
+ Error :: CrossCompilation => write ! ( f, "CrossCompilation" ) ,
182
+ Error :: Command { ref command, ref cause } => {
181
183
f. debug_struct ( "Command" )
182
- . field ( "command" , command)
183
- . field ( "cause" , cause)
184
- . finish ( )
184
+ . field ( "command" , command)
185
+ . field ( "cause" , cause)
186
+ . finish ( )
185
187
}
186
- Failure { ref command, ref output } => {
188
+ Error :: Failure { ref command, ref output } => {
187
189
f. debug_struct ( "Failure" )
188
- . field ( "command" , command)
189
- . field ( "output" , & OutputDebugger ( output) )
190
- . finish ( )
190
+ . field ( "command" , command)
191
+ . field ( "output" , & OutputDebugger ( output) )
192
+ . finish ( )
191
193
}
192
- __Nonexhaustive => write ! ( f , "__Nonexhaustive" ) ,
194
+ Error :: __Nonexhaustive => panic ! ( ) ,
193
195
}
194
196
}
195
197
}
196
198
197
199
impl fmt:: Display for Error {
198
200
fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
199
- use self :: Error :: * ;
200
201
match * self {
201
- EnvNoPkgConfig ( ref name) => {
202
+ Error :: EnvNoPkgConfig ( ref name) => {
202
203
write ! ( f, "Aborted because {} is set" , name)
203
204
}
204
- CrossCompilation => {
205
+ Error :: CrossCompilation => {
205
206
write ! ( f, "Cross compilation detected. \
206
207
Use PKG_CONFIG_ALLOW_CROSS=1 to override")
207
208
}
208
- Command { ref command, ref cause } => {
209
+ Error :: Command { ref command, ref cause } => {
209
210
write ! ( f, "Failed to run `{}`: {}" , command, cause)
210
211
}
211
- Failure { ref command, ref output } => {
212
+ Error :: Failure { ref command, ref output } => {
212
213
let stdout = str:: from_utf8 ( & output. stdout ) . unwrap ( ) ;
213
214
let stderr = str:: from_utf8 ( & output. stderr ) . unwrap ( ) ;
214
215
try!( write ! ( f, "`{}` did not exit successfully: {}" , command, output. status) ) ;
@@ -220,13 +221,13 @@ impl fmt::Display for Error {
220
221
}
221
222
Ok ( ( ) )
222
223
}
223
- __Nonexhaustive => unreachable ! ( ) ,
224
+ Error :: __Nonexhaustive => panic ! ( ) ,
224
225
}
225
226
}
226
227
}
227
228
229
+ /// Deprecated in favor of the probe_library function
228
230
#[ doc( hidden) ]
229
- //#[deprecated(since = "0.3.7", note = "use `probe_library` instead")]
230
231
pub fn find_library ( name : & str ) -> Result < Library , String > {
231
232
probe_library ( name) . map_err ( |e| e. to_string ( ) )
232
233
}
@@ -278,8 +279,8 @@ impl Config {
278
279
self
279
280
}
280
281
282
+ /// Deprecated in favor fo the `probe` function
281
283
#[ doc( hidden) ]
282
- //#[deprecated(since = "0.3.7", note = "use `probe` instead")]
283
284
pub fn find ( & self , name : & str ) -> Result < Library , String > {
284
285
self . probe ( name) . map_err ( |e| e. to_string ( ) )
285
286
}
@@ -307,8 +308,8 @@ impl Config {
307
308
Ok ( library)
308
309
}
309
310
311
+ /// Deprecated in favor of the top level `get_variable` function
310
312
#[ doc( hidden) ]
311
- //#[deprecated(since = "0.3.7", note = "use the `get_variable` free function instead")]
312
313
pub fn get_variable ( package : & str , variable : & str ) -> Result < String , String > {
313
314
get_variable ( package, variable) . map_err ( |e| e. to_string ( ) )
314
315
}
0 commit comments