Skip to content

Commit ccb7c88

Browse files
committed
Touch up some style here and there
1 parent c9921ee commit ccb7c88

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "pkg-config"
4-
version = "0.3.7"
4+
version = "0.3.6"
55
authors = ["Alex Crichton <[email protected]>"]
66
license = "MIT/Apache-2.0"
77
repository = "https://github.com/alexcrichton/pkg-config-rs"

src/lib.rs

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
//! extern crate pkg_config;
3737
//!
3838
//! fn main() {
39-
//! pkg_config::find_library("foo").unwrap();
39+
//! pkg_config::probe_library("foo").unwrap();
4040
//! }
4141
//! ```
4242
//!
@@ -46,7 +46,7 @@
4646
//! extern crate pkg_config;
4747
//!
4848
//! fn main() {
49-
//! pkg_config::Config::new().statik(true).find("foo").unwrap();
49+
//! pkg_config::Config::new().statik(true).probe("foo").unwrap();
5050
//! }
5151
//! ```
5252
@@ -100,35 +100,38 @@ pub enum Error {
100100
///
101101
/// Contains the name of the responsible environment variable.
102102
EnvNoPkgConfig(String),
103+
103104
/// Cross compilation detected.
104105
///
105106
/// Override with `PKG_CONFIG_ALLOW_CROSS=1`.
106107
CrossCompilation,
108+
107109
/// Failed to run `pkg-config`.
108110
///
109111
/// Contains the command and the cause.
110112
Command { command: String, cause: io::Error },
113+
111114
/// `pkg-config` did not exit sucessfully.
112115
///
113116
/// Contains the command and output.
114117
Failure { command: String, output: Output },
118+
115119
#[doc(hidden)]
116120
// please don't match on this, we're likely to add more variants over time
117121
__Nonexhaustive,
118122
}
119123

120124
impl error::Error for Error {
121125
fn description(&self) -> &str {
122-
use self::Error::*;
123126
match *self {
124-
EnvNoPkgConfig(_) => "pkg-config requested to be aborted",
125-
CrossCompilation => {
127+
Error::EnvNoPkgConfig(_) => "pkg-config requested to be aborted",
128+
Error::CrossCompilation => {
126129
"pkg-config doesn't handle cross compilation. \
127130
Use PKG_CONFIG_ALLOW_CROSS=1 to override"
128131
}
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!(),
132135
}
133136
}
134137

@@ -159,56 +162,54 @@ impl<'a> fmt::Debug for OutputDebugger<'a> {
159162
};
160163

161164
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()
166169
}
167170
}
168171

169172
// Workaround for temporary lack of impl Debug for Output in stable std, continued
170173
impl fmt::Debug for Error {
171174
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
172-
use self::Error::*;
173175
match *self {
174-
EnvNoPkgConfig(ref name) => {
176+
Error::EnvNoPkgConfig(ref name) => {
175177
f.debug_tuple("EnvNoPkgConfig")
176-
.field(name)
177-
.finish()
178+
.field(name)
179+
.finish()
178180
}
179-
CrossCompilation => write!(f, "CrossCompilation"),
180-
Command { ref command, ref cause } => {
181+
Error::CrossCompilation => write!(f, "CrossCompilation"),
182+
Error::Command { ref command, ref cause } => {
181183
f.debug_struct("Command")
182-
.field("command", command)
183-
.field("cause", cause)
184-
.finish()
184+
.field("command", command)
185+
.field("cause", cause)
186+
.finish()
185187
}
186-
Failure { ref command, ref output } => {
188+
Error::Failure { ref command, ref output } => {
187189
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()
191193
}
192-
__Nonexhaustive => write!(f, "__Nonexhaustive"),
194+
Error::__Nonexhaustive => panic!(),
193195
}
194196
}
195197
}
196198

197199
impl fmt::Display for Error {
198200
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
199-
use self::Error::*;
200201
match *self {
201-
EnvNoPkgConfig(ref name) => {
202+
Error::EnvNoPkgConfig(ref name) => {
202203
write!(f, "Aborted because {} is set", name)
203204
}
204-
CrossCompilation => {
205+
Error::CrossCompilation => {
205206
write!(f, "Cross compilation detected. \
206207
Use PKG_CONFIG_ALLOW_CROSS=1 to override")
207208
}
208-
Command { ref command, ref cause } => {
209+
Error::Command { ref command, ref cause } => {
209210
write!(f, "Failed to run `{}`: {}", command, cause)
210211
}
211-
Failure { ref command, ref output } => {
212+
Error::Failure { ref command, ref output } => {
212213
let stdout = str::from_utf8(&output.stdout).unwrap();
213214
let stderr = str::from_utf8(&output.stderr).unwrap();
214215
try!(write!(f, "`{}` did not exit successfully: {}", command, output.status));
@@ -220,13 +221,13 @@ impl fmt::Display for Error {
220221
}
221222
Ok(())
222223
}
223-
__Nonexhaustive => unreachable!(),
224+
Error::__Nonexhaustive => panic!(),
224225
}
225226
}
226227
}
227228

229+
/// Deprecated in favor of the probe_library function
228230
#[doc(hidden)]
229-
//#[deprecated(since = "0.3.7", note = "use `probe_library` instead")]
230231
pub fn find_library(name: &str) -> Result<Library, String> {
231232
probe_library(name).map_err(|e| e.to_string())
232233
}
@@ -278,8 +279,8 @@ impl Config {
278279
self
279280
}
280281

282+
/// Deprecated in favor fo the `probe` function
281283
#[doc(hidden)]
282-
//#[deprecated(since = "0.3.7", note = "use `probe` instead")]
283284
pub fn find(&self, name: &str) -> Result<Library, String> {
284285
self.probe(name).map_err(|e| e.to_string())
285286
}
@@ -307,8 +308,8 @@ impl Config {
307308
Ok(library)
308309
}
309310

311+
/// Deprecated in favor of the top level `get_variable` function
310312
#[doc(hidden)]
311-
//#[deprecated(since = "0.3.7", note = "use the `get_variable` free function instead")]
312313
pub fn get_variable(package: &str, variable: &str) -> Result<String, String> {
313314
get_variable(package, variable).map_err(|e| e.to_string())
314315
}

0 commit comments

Comments
 (0)