Remove some as_slice calls.

This commit is contained in:
Ms2ger 2015-04-24 17:40:22 +02:00
parent 4ee89363fb
commit 6a55ae06d7
34 changed files with 79 additions and 79 deletions

View file

@ -8,7 +8,7 @@ use string_cache::{Atom, Namespace};
pub fn from_domstring(url: Option<DOMString>) -> Namespace {
match url {
None => ns!(""),
Some(ref s) => Namespace(Atom::from_slice(s.as_slice())),
Some(ref s) => Namespace(Atom::from_slice(s)),
}
}

View file

@ -145,7 +145,7 @@ pub struct Opts {
fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
let message = format!("Usage: {} [ options ... ] [URL]\n\twhere options include", app);
println!("{}", getopts::usage(message.as_slice(), opts));
println!("{}", getopts::usage(&message, opts));
}
pub fn print_debug_usage(app: &str) {
@ -262,16 +262,16 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
getopts::optflag("", "sniff-mime-types" , "Enable MIME sniffing"),
);
let opt_match = match getopts::getopts(args, opts.as_slice()) {
let opt_match = match getopts::getopts(args, &opts) {
Ok(m) => m,
Err(f) => {
args_fail(f.to_string().as_slice());
args_fail(&f.to_string());
return false;
}
};
if opt_match.opt_present("h") || opt_match.opt_present("help") {
print_usage(app_name.as_slice(), opts.as_slice());
print_usage(&app_name, &opts);
return false;
};
@ -280,16 +280,16 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
None => String::new()
};
let mut debug_options = HashSet::new();
for split in debug_string.as_slice().split(',') {
for split in debug_string.split(',') {
debug_options.insert(split.clone());
}
if debug_options.contains(&"help") {
print_debug_usage(app_name.as_slice());
print_debug_usage(&app_name);
return false;
}
let url = if opt_match.free.is_empty() {
print_usage(app_name.as_slice(), opts.as_slice());
print_usage(&app_name, &opts);
args_fail("servo asks that you provide a URL");
return false;
} else {

View file

@ -12,6 +12,7 @@ use std::borrow::ToOwned;
use std::ffi::CStr;
use std::iter::Filter;
use std::num::{Int, ToPrimitive};
use std::ops::Deref;
use std::str::{from_utf8, FromStr, Split};
pub type DOMString = String;
@ -29,7 +30,7 @@ pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString {
pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
match *s {
Some(ref s) => s.as_slice(),
Some(ref s) => s,
None => ""
}
}
@ -231,7 +232,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> {
new_input.push(ch)
}
}
let mut input = new_input.as_slice();
let mut input = &*new_input;
// Step 8.
for (char_count, (index, _)) in input.char_indices().enumerate() {
@ -328,9 +329,11 @@ impl LowercaseString {
}
}
impl Str for LowercaseString {
impl Deref for LowercaseString {
type Target = str;
#[inline]
fn as_slice(&self) -> &str {
fn deref(&self) -> &str {
&*self.inner
}
}