cleanup: replace as[_mut]_slice() calls with deref coercions
This commit is contained in:
@@ -178,12 +178,12 @@ pub fn opts() -> Vec<getopts::OptGroup> {
|
||||
|
||||
pub fn usage(argv0: &str) {
|
||||
println!("{}",
|
||||
getopts::usage(format!("{} [options] <input>", argv0).as_slice(),
|
||||
opts().as_slice()));
|
||||
getopts::usage(&format!("{} [options] <input>", argv0),
|
||||
&opts()));
|
||||
}
|
||||
|
||||
pub fn main_args(args: &[String]) -> int {
|
||||
let matches = match getopts::getopts(args.tail(), opts().as_slice()) {
|
||||
let matches = match getopts::getopts(args.tail(), &opts()) {
|
||||
Ok(m) => m,
|
||||
Err(err) => {
|
||||
println!("{}", err);
|
||||
@@ -191,7 +191,7 @@ pub fn main_args(args: &[String]) -> int {
|
||||
}
|
||||
};
|
||||
if matches.opt_present("h") || matches.opt_present("help") {
|
||||
usage(args[0].as_slice());
|
||||
usage(&args[0]);
|
||||
return 0;
|
||||
} else if matches.opt_present("version") {
|
||||
rustc_driver::version("rustdoc", &matches);
|
||||
@@ -217,11 +217,11 @@ pub fn main_args(args: &[String]) -> int {
|
||||
println!("only one input file may be specified");
|
||||
return 1;
|
||||
}
|
||||
let input = matches.free[0].as_slice();
|
||||
let input = &matches.free[0];
|
||||
|
||||
let mut libs = SearchPaths::new();
|
||||
for s in &matches.opt_strs("L") {
|
||||
libs.add_path(s.as_slice());
|
||||
libs.add_path(s);
|
||||
}
|
||||
let externs = match parse_externs(&matches) {
|
||||
Ok(ex) => ex,
|
||||
@@ -244,9 +244,9 @@ pub fn main_args(args: &[String]) -> int {
|
||||
let cfgs = matches.opt_strs("cfg");
|
||||
|
||||
let external_html = match ExternalHtml::load(
|
||||
matches.opt_strs("html-in-header").as_slice(),
|
||||
matches.opt_strs("html-before-content").as_slice(),
|
||||
matches.opt_strs("html-after-content").as_slice()) {
|
||||
&matches.opt_strs("html-in-header"),
|
||||
&matches.opt_strs("html-before-content"),
|
||||
&matches.opt_strs("html-after-content")) {
|
||||
Some(eh) => eh,
|
||||
None => return 3
|
||||
};
|
||||
@@ -274,7 +274,7 @@ pub fn main_args(args: &[String]) -> int {
|
||||
};
|
||||
let Output { krate, json_plugins, passes, } = out;
|
||||
info!("going to format");
|
||||
match matches.opt_str("w").as_ref().map(|s| s.as_slice()) {
|
||||
match matches.opt_str("w").as_ref().map(|s| &**s) {
|
||||
Some("html") | None => {
|
||||
match html::render::run(krate, &external_html, output.unwrap_or(Path::new("doc")),
|
||||
passes.into_iter().collect()) {
|
||||
@@ -303,7 +303,7 @@ pub fn main_args(args: &[String]) -> int {
|
||||
fn acquire_input(input: &str,
|
||||
externs: core::Externs,
|
||||
matches: &getopts::Matches) -> Result<Output, String> {
|
||||
match matches.opt_str("r").as_ref().map(|s| s.as_slice()) {
|
||||
match matches.opt_str("r").as_ref().map(|s| &**s) {
|
||||
Some("rust") => Ok(rust_input(input, externs, matches)),
|
||||
Some("json") => json_input(input),
|
||||
Some(s) => Err(format!("unknown input format: {}", s)),
|
||||
@@ -357,7 +357,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
|
||||
// First, parse the crate and extract all relevant information.
|
||||
let mut paths = SearchPaths::new();
|
||||
for s in &matches.opt_strs("L") {
|
||||
paths.add_path(s.as_slice());
|
||||
paths.add_path(s);
|
||||
}
|
||||
let cfgs = matches.opt_strs("cfg");
|
||||
let triple = matches.opt_str("target");
|
||||
@@ -512,7 +512,7 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
|
||||
// FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
|
||||
// straight to the Rust JSON representation.
|
||||
let crate_json_str = format!("{}", json::as_json(&krate));
|
||||
let crate_json = match json::from_str(crate_json_str.as_slice()) {
|
||||
let crate_json = match json::from_str(&crate_json_str) {
|
||||
Ok(j) => j,
|
||||
Err(e) => panic!("Rust generated JSON is invalid: {:?}", e)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user