libgetopts: Remove all uses of ~str from libgetopts

This commit is contained in:
Patrick Walton
2014-05-14 21:39:11 -07:00
parent 28bcef85e4
commit 1fb08f11b7
8 changed files with 275 additions and 248 deletions

View File

@@ -137,12 +137,7 @@ pub fn usage(argv0: &str) {
}
pub fn main_args(args: &[StrBuf]) -> int {
let matches = match getopts::getopts(args.tail()
.iter()
.map(|x| (*x).to_owned())
.collect::<Vec<_>>()
.as_slice(),
opts().as_slice()) {
let matches = match getopts::getopts(args.tail(), opts().as_slice()) {
Ok(m) => m,
Err(err) => {
println!("{}", err.to_err_msg());
@@ -170,7 +165,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
let test_args = matches.opt_strs("test-args");
let test_args: Vec<StrBuf> = test_args.iter()
.flat_map(|s| s.words())
.flat_map(|s| s.as_slice().words())
.map(|s| s.to_strbuf())
.collect();
@@ -199,7 +194,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
(false, false) => {}
}
if matches.opt_strs("passes").as_slice() == &["list".to_owned()] {
if matches.opt_strs("passes").as_slice() == &["list".to_strbuf()] {
println!("Available passes for running rustdoc:");
for &(name, _, description) in PASSES.iter() {
println!("{:>20s} - {}", name, description);
@@ -306,7 +301,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
clean::NameValue(ref x, ref value)
if "passes" == x.as_slice() => {
for pass in value.as_slice().words() {
passes.push(pass.to_owned());
passes.push(pass.to_strbuf());
}
}
clean::NameValue(ref x, ref value)
@@ -323,15 +318,19 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
}
if default_passes {
for name in DEFAULT_PASSES.iter().rev() {
passes.unshift(name.to_owned());
passes.unshift(name.to_strbuf());
}
}
// Load all plugins/passes into a PluginManager
let path = matches.opt_str("plugin-path").unwrap_or("/tmp/rustdoc/plugins".to_owned());
let path = matches.opt_str("plugin-path")
.unwrap_or("/tmp/rustdoc/plugins".to_strbuf());
let mut pm = plugins::PluginManager::new(Path::new(path));
for pass in passes.iter() {
let plugin = match PASSES.iter().position(|&(p, _, _)| p == *pass) {
let plugin = match PASSES.iter()
.position(|&(p, _, _)| {
p == pass.as_slice()
}) {
Some(i) => PASSES[i].val1(),
None => {
error!("unknown pass {}, skipping", *pass);