diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-04-24 17:40:22 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-04-24 17:44:47 +0200 |
commit | 6a55ae06d75e6997b54b56e006b0ba8a5dfb1fc6 (patch) | |
tree | 857a782c74937a216305a13eff73607a591bd196 | |
parent | 4ee89363fb6d538e28dd9375e69580d139ddacea (diff) | |
download | servo-6a55ae06d75e6997b54b56e006b0ba8a5dfb1fc6.tar.gz servo-6a55ae06d75e6997b54b56e006b0ba8a5dfb1fc6.zip |
Remove some as_slice calls.
34 files changed, 79 insertions, 79 deletions
diff --git a/components/gfx/buffer_map.rs b/components/gfx/buffer_map.rs index 01070851d88..e0cf4d22682 100644 --- a/components/gfx/buffer_map.rs +++ b/components/gfx/buffer_map.rs @@ -32,7 +32,7 @@ struct BufferKey([usize; 2]); impl Hash for BufferKey { fn hash<H: Hasher>(&self, state: &mut H) { let BufferKey(ref bytes) = *self; - bytes.as_slice().hash(state); + bytes.hash(state); } } diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs index b3332e2a2e4..24e36ba3163 100644 --- a/components/gfx/font_cache_task.rs +++ b/components/gfx/font_cache_task.rs @@ -8,7 +8,6 @@ use platform::font_list::get_variations_for_family; use platform::font_list::get_last_resort_font_families; use platform::font_context::FontContextHandle; -use collections::str::Str; use font_template::{FontTemplate, FontTemplateDescriptor}; use net_traits::{ResourceTask, load_whole_resource}; use platform::font_template::FontTemplateData; @@ -106,7 +105,7 @@ fn add_generic_font(generic_fonts: &mut HashMap<LowercaseString, LowercaseString generic_name: &str, mapped_name: &str) { let opt_system_default = get_system_default_family(generic_name); let family_name = match opt_system_default { - Some(system_default) => LowercaseString::new(system_default.as_slice()), + Some(system_default) => LowercaseString::new(&system_default), None => LowercaseString::new(mapped_name), }; generic_fonts.insert(LowercaseString::new(generic_name), family_name); @@ -119,7 +118,7 @@ impl FontCache { match msg { Command::GetFontTemplate(family, descriptor, result) => { - let family = LowercaseString::new(family.as_slice()); + let family = LowercaseString::new(&family); let maybe_font_template = self.get_font_template(&family, &descriptor); result.send(Reply::GetFontTemplateReply(maybe_font_template)).unwrap(); } @@ -128,7 +127,7 @@ impl FontCache { result.send(Reply::GetFontTemplateReply(Some(font_template))).unwrap(); } Command::AddWebFont(family_name, src, result) => { - let family_name = LowercaseString::new(family_name.as_slice()); + let family_name = LowercaseString::new(&family_name); if !self.web_families.contains_key(&family_name) { let family = FontFamily::new(); self.web_families.insert(family_name.clone(), family); @@ -141,7 +140,7 @@ impl FontCache { match maybe_resource { Ok((_, bytes)) => { let family = &mut self.web_families[family_name]; - family.add_template(url.to_string().as_slice(), Some(bytes)); + family.add_template(&url.to_string(), Some(bytes)); }, Err(_) => { debug!("Failed to load web font: family={:?} url={}", family_name, url); @@ -150,8 +149,8 @@ impl FontCache { } Source::Local(ref local_family_name) => { let family = &mut self.web_families[family_name]; - get_variations_for_family(local_family_name.as_slice(), |path| { - family.add_template(path.as_slice(), None); + get_variations_for_family(&local_family_name, |path| { + family.add_template(&path, None); }); } } @@ -168,7 +167,7 @@ impl FontCache { fn refresh_local_families(&mut self) { self.local_families.clear(); get_available_families(|family_name| { - let family_name = LowercaseString::new(family_name.as_slice()); + let family_name = LowercaseString::new(&family_name); if !self.local_families.contains_key(&family_name) { let family = FontFamily::new(); self.local_families.insert(family_name, family); @@ -188,12 +187,12 @@ impl FontCache { // TODO(Issue #188): look up localized font family names if canonical name not found // look up canonical name if self.local_families.contains_key(family_name) { - debug!("FontList: Found font family with name={}", family_name.as_slice()); + debug!("FontList: Found font family with name={}", &**family_name); let s = &mut self.local_families[*family_name]; if s.templates.len() == 0 { - get_variations_for_family(family_name.as_slice(), |path| { - s.add_template(path.as_slice(), None); + get_variations_for_family(&family_name, |path| { + s.add_template(&path, None); }); } @@ -206,7 +205,7 @@ impl FontCache { None } else { - debug!("FontList: Couldn't find font family with name={}", family_name.as_slice()); + debug!("FontList: Couldn't find font family with name={}", &**family_name); None } } @@ -237,7 +236,7 @@ impl FontCache { let last_resort = get_last_resort_font_families(); for family in last_resort.iter() { - let family = LowercaseString::new(family.as_slice()); + let family = LowercaseString::new(family); let maybe_font_in_family = self.find_font_in_local_family(&family, desc); if maybe_font_in_family.is_some() { return maybe_font_in_family.unwrap(); diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 860bb62b375..534c844cb87 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -164,7 +164,7 @@ impl FontContext { // GWTODO: Check on real pages if this is faster as Vec() or HashMap(). let mut cache_hit = false; for cached_font_entry in self.layout_font_cache.iter() { - if cached_font_entry.family.as_slice() == family.name() { + if cached_font_entry.family == family.name() { match cached_font_entry.font { None => { cache_hit = true; diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs index 50cf8c57fee..e30eff4bd33 100644 --- a/components/gfx/font_template.rs +++ b/components/gfx/font_template.rs @@ -158,7 +158,7 @@ impl FontTemplate { } assert!(self.strong_ref.is_none()); - let template_data = Arc::new(FontTemplateData::new(self.identifier.as_slice(), None)); + let template_data = Arc::new(FontTemplateData::new(&self.identifier, None)); self.weak_ref = Some(template_data.downgrade()); template_data } diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 93c7604c3d9..1af8b8f695d 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -133,8 +133,8 @@ impl<'a> PaintContext<'a> { image_rendering: image_rendering::T) { let size = Size2D(image.width as i32, image.height as i32); let (pixel_width, pixels, source_format) = match image.pixels { - PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8), - PixelsByColorType::K8(ref pixels) => (1, pixels.as_slice(), SurfaceFormat::A8), + PixelsByColorType::RGBA8(ref pixels) => (4, pixels, SurfaceFormat::B8G8R8A8), + PixelsByColorType::K8(ref pixels) => (1, pixels, SurfaceFormat::A8), PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"), PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"), }; diff --git a/components/gfx/platform/macos/font_list.rs b/components/gfx/platform/macos/font_list.rs index 4e327cea1b8..d5d221f375e 100644 --- a/components/gfx/platform/macos/font_list.rs +++ b/components/gfx/platform/macos/font_list.rs @@ -24,7 +24,7 @@ pub fn get_variations_for_family<F>(family_name: &str, mut callback: F) where F: debug!("Looking for faces of family: {}", family_name); let family_collection = - core_text::font_collection::create_for_family(family_name.as_slice()); + core_text::font_collection::create_for_family(family_name); match family_collection { Some(family_collection) => { let family_descriptors = family_collection.get_descriptors(); diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs index 02865733990..a4cda3b5a66 100644 --- a/components/gfx/platform/macos/font_template.rs +++ b/components/gfx/platform/macos/font_template.rs @@ -26,7 +26,7 @@ impl FontTemplateData { pub fn new(identifier: &str, font_data: Option<Vec<u8>>) -> FontTemplateData { let ctfont = match font_data { Some(ref bytes) => { - let fontprov = CGDataProvider::from_buffer(bytes.as_slice()); + let fontprov = CGDataProvider::from_buffer(bytes); let cgfont_result = CGFont::from_data_provider(fontprov); match cgfont_result { Ok(cgfont) => Some(core_text::font::new_from_CGFont(&cgfont, 0.0)), @@ -34,7 +34,7 @@ impl FontTemplateData { } }, None => { - Some(core_text::font::new_from_name(identifier.as_slice(), 0.0).unwrap()) + Some(core_text::font::new_from_name(&identifier, 0.0).unwrap()) } }; diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 23e9664fd9f..ba60e67e9a1 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -359,7 +359,7 @@ impl<'a> DetailedGlyphStore { detail_offset: 0, // unused }; - let i = (&*self.detail_lookup).binary_search_index(&key) + let i = self.detail_lookup.binary_search_index(&key) .expect("Invalid index not found in detailed glyph lookup table!"); assert!(i + (count as usize) <= self.detail_buffer.len()); @@ -379,7 +379,7 @@ impl<'a> DetailedGlyphStore { detail_offset: 0, // unused }; - let i = self.detail_lookup.as_slice().binary_search_index(&key) + let i = self.detail_lookup.binary_search_index(&key) .expect("Invalid index not found in detailed glyph lookup table!"); assert!(i + (detail_offset as usize) < self.detail_buffer.len()); diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 2331afc65b2..e79982130c2 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -119,7 +119,7 @@ impl<'a> Eq for ApplicableDeclarationsCacheQuery<'a> {} impl<'a> PartialEq<ApplicableDeclarationsCacheEntry> for ApplicableDeclarationsCacheQuery<'a> { fn eq(&self, other: &ApplicableDeclarationsCacheEntry) -> bool { - let other_as_query = ApplicableDeclarationsCacheQuery::new(other.declarations.as_slice()); + let other_as_query = ApplicableDeclarationsCacheQuery::new(&other.declarations); self.eq(&other_as_query) } } @@ -279,7 +279,7 @@ impl StyleSharingCandidate { match (&self.class, element.get_attr(&ns!(""), &atom!("class"))) { (&None, Some(_)) | (&Some(_), None) => return false, (&Some(ref this_class), Some(element_class)) if - element_class != this_class.as_slice() => { + element_class != &**this_class => { return false } (&Some(_), Some(_)) | (&None, None) => {} diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index ce0defe256b..3d683bed03f 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -1506,7 +1506,7 @@ impl Fragment { } match self.specific { SpecificFragmentInfo::UnscannedText(ref text_fragment_info) => { - util::str::is_whitespace(text_fragment_info.text.as_slice()) + util::str::is_whitespace(&text_fragment_info.text) } _ => false, } diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index 1468213fca6..d0cf0af98d1 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -186,7 +186,7 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> { let mut temporary_counter = Counter::new(); let counter = self.traversal .counters - .get(counter_name.as_slice()) + .get(&*counter_name) .unwrap_or(&mut temporary_counter); new_info = counter.render(self.traversal.layout_context, fragment.node, @@ -200,13 +200,13 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> { let mut temporary_counter = Counter::new(); let counter = self.traversal .counters - .get(counter_name.as_slice()) + .get(&*counter_name) .unwrap_or(&mut temporary_counter); new_info = counter.render(self.traversal.layout_context, fragment.node, fragment.style.clone(), counter_style, - RenderingMode::All(separator.as_slice())); + RenderingMode::All(&separator)); } GeneratedContentInfo::ContentItem(ContentItem::OpenQuote) => { new_info = Some(render_text(self.traversal.layout_context, diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 6d2339e5355..316022eec6c 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1384,7 +1384,7 @@ impl Flow for InlineFlow { kid.assign_block_size_for_inorder_child_if_necessary(layout_context, thread_id); } - self.base.position.size.block = match self.lines.as_slice().last() { + self.base.position.size.block = match self.lines.last() { Some(ref last_line) => last_line.bounds.start.b + last_line.bounds.size.block, None => Au(0), }; diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 3339eb9de0d..bf2ee6e660c 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -600,7 +600,7 @@ impl LayoutTask { // TODO we don't really even need to load this if mq does not match let (metadata, iter) = load_bytes_iter(&self.resource_task, url); - let protocol_encoding_label = metadata.charset.as_ref().map(|s| s.as_slice()); + let protocol_encoding_label = metadata.charset.as_ref().map(|s| &**s); let final_url = metadata.final_url; let sheet = Stylesheet::from_bytes_iter(iter, diff --git a/components/layout/table.rs b/components/layout/table.rs index ecf36891c50..02cae3c81c9 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -169,7 +169,7 @@ impl TableFlow { TableLayout::Auto => { computation.union_block(&TableFlow::update_automatic_column_inline_sizes( column_inline_sizes, - row.cell_intrinsic_inline_sizes.as_slice())) + &row.cell_intrinsic_inline_sizes)) } } } @@ -348,7 +348,7 @@ impl Flow for TableFlow { self.block_flow.base.flags.remove(IMPACTED_BY_RIGHT_FLOATS); let info = ChildInlineSizeInfo { - column_computed_inline_sizes: self.column_computed_inline_sizes.as_slice(), + column_computed_inline_sizes: &self.column_computed_inline_sizes, spacing: spacing_per_cell, }; self.block_flow.propagate_assigned_inline_size_to_children(layout_context, diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 5a8b192d2a4..00958547f20 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -281,7 +281,7 @@ impl Flow for TableRowFlow { // Push those inline sizes down to the cells. let info = ChildInlineSizeInfo { - column_computed_inline_sizes: computed_inline_size_for_cells.as_slice(), + column_computed_inline_sizes: &computed_inline_size_for_cells, spacing: self.spacing, }; self.block_flow.propagate_assigned_inline_size_to_children(layout_context, diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 64f39412a33..85f095b3076 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -111,7 +111,7 @@ impl Flow for TableRowGroupFlow { containing_block_inline_size); let info = ChildInlineSizeInfo { - column_computed_inline_sizes: self.column_computed_inline_sizes.as_slice(), + column_computed_inline_sizes: &self.column_computed_inline_sizes, spacing: self.spacing, }; self.block_flow.propagate_assigned_inline_size_to_children(layout_context, diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 290876e05b0..cfc2469e443 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -324,7 +324,7 @@ impl Flow for TableWrapperFlow { } Some(ref assigned_column_inline_sizes) => { let info = ChildInlineSizeInfo { - column_computed_inline_sizes: assigned_column_inline_sizes.as_slice(), + column_computed_inline_sizes: &assigned_column_inline_sizes, spacing: self.block_flow.fragment.style().get_inheritedtable().border_spacing, }; self.block_flow diff --git a/components/layout/text.rs b/components/layout/text.rs index 0844eadb359..bf0168f9a1c 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -142,7 +142,7 @@ impl TextRunScanner { }; let old_length = CharIndex(run_text.chars().count() as isize); - last_whitespace = util::transform_text(in_fragment.as_slice(), + last_whitespace = util::transform_text(&in_fragment, compression, last_whitespace, &mut run_text); diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index e6d314c5ed8..8c30d649db3 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -254,7 +254,7 @@ impl<'ln> LayoutNode<'ln> { s.push_str(" "); } - s.push_str(self.debug_str().as_slice()); + s.push_str(&self.debug_str()); println!("{}", s); for kid in self.children() { diff --git a/components/net/image_cache_task.rs b/components/net/image_cache_task.rs index 54949d53b54..d4e7f3c98b6 100644 --- a/components/net/image_cache_task.rs +++ b/components/net/image_cache_task.rs @@ -233,7 +233,7 @@ impl ImageCache { ResponseAction::HeadersAvailable(_) => {} ResponseAction::DataAvailable(data) => { let pending_load = self.pending_loads.get_mut(&msg.url).unwrap(); - pending_load.bytes.push_all(data.as_slice()); + pending_load.bytes.push_all(&data); } ResponseAction::ResponseComplete(result) => { match result { @@ -246,7 +246,7 @@ impl ImageCache { let sender = self.decoder_sender.clone(); self.task_pool.execute(move || { - let image = load_from_memory(bytes.as_slice()); + let image = load_from_memory(&bytes); let msg = DecoderMsg { url: url, image: image diff --git a/components/net/mime_classifier.rs b/components/net/mime_classifier.rs index 7d792cfb6f7..db44f1ec38f 100644 --- a/components/net/mime_classifier.rs +++ b/components/net/mime_classifier.rs @@ -28,7 +28,7 @@ impl MIMEClassifier { return self.sniff_unknown_type(!no_sniff, data); } Some((ref media_type, ref media_subtype)) => { - match (media_type.as_slice(), media_subtype.as_slice()) { + match (&**media_type, &**media_subtype) { ("uknown", "unknown") | ("application", "uknown") | ("*", "*") => { return self.sniff_unknown_type(!no_sniff,data); } @@ -50,14 +50,14 @@ impl MIMEClassifier { .or(supplied_type.clone()); } - if media_type.as_slice() == "image" { + if &**media_type == "image" { let tp = self.image_classifier.classify(data); if tp.is_some() { return tp; } } - match (media_type.as_slice(), media_subtype.as_slice()) { + match (&**media_type, &**media_subtype) { ("audio", _) | ("video", _) | ("application", "ogg") => { let tp = self.audio_video_classifer.classify(data); if tp.is_some() { diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs index 604561addc3..4a14fdd6255 100644 --- a/components/net_traits/image/base.rs +++ b/components/net_traits/image/base.rs @@ -34,9 +34,9 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> { match png::load_png_from_memory(buffer) { Ok(mut png_image) => { match png_image.pixels { - png::PixelsByColorType::RGB8(ref mut data) => byte_swap(data.as_mut_slice()), + png::PixelsByColorType::RGB8(ref mut data) => byte_swap(data), png::PixelsByColorType::RGBA8(ref mut data) => { - byte_swap_and_premultiply(data.as_mut_slice()) + byte_swap_and_premultiply(data) } _ => {} } @@ -54,9 +54,9 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> { assert!(image.depth == 4); // handle gif separately because the alpha-channel has to be premultiplied if is_gif(buffer) { - byte_swap_and_premultiply(image.data.as_mut_slice()); + byte_swap_and_premultiply(&mut image.data); } else { - byte_swap(image.data.as_mut_slice()); + byte_swap(&mut image.data); } Some(png::Image { width: image.width as u32, diff --git a/components/plugins/casing.rs b/components/plugins/casing.rs index a6fc4a6c53e..98cefc658b2 100644 --- a/components/plugins/casing.rs +++ b/components/plugins/casing.rs @@ -48,11 +48,11 @@ fn expand_cased<'cx, T>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree], match (res, it.count()) { (Some((s, span)), 0) => { let new_s = s.chars().map(transform).collect::<String>(); - base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(new_s.as_slice()))) + base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(&new_s))) } (_, rest) => { if rest > 0 { - cx.span_err(sp, format!("expected 1 argument, found {}", rest+1).as_slice()); + cx.span_err(sp, &format!("expected 1 argument, found {}", rest+1)); } base::DummyResult::expr(sp) } diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index 3a7da6a20f8..968676b5413 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -12,7 +12,7 @@ //! - `#[dom_struct]` : Implies `#[privatize]`,`#[jstraceable]`, and `#[must_root]`. //! Use this for structs that correspond to a DOM type -#![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, core, unicode)] +#![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, unicode)] #[macro_use] extern crate syntax; diff --git a/components/plugins/lints/transmute_type.rs b/components/plugins/lints/transmute_type.rs index 25b931bce87..0808e87cc09 100644 --- a/components/plugins/lints/transmute_type.rs +++ b/components/plugins/lints/transmute_type.rs @@ -32,10 +32,10 @@ impl LintPass for TransmutePass { && args.len() == 1 { let tcx = cx.tcx; cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span, - format!("Transmute to {} from {} detected", + &format!("Transmute to {} from {} detected", expr_ty(tcx, ex).repr(tcx), expr_ty(tcx, &**args.get(0).unwrap()).repr(tcx) - ).as_slice()); + )); } } _ => {} diff --git a/components/plugins/lints/unrooted_must_root.rs b/components/plugins/lints/unrooted_must_root.rs index 2fd6ad93dbd..3150c7da5e6 100644 --- a/components/plugins/lints/unrooted_must_root.rs +++ b/components/plugins/lints/unrooted_must_root.rs @@ -150,7 +150,7 @@ impl LintPass for UnrootedPass { ty::ty_enum(did, _) => { if ty::has_attr(cx.tcx, did, "must_root") { cx.span_lint(UNROOTED_MUST_ROOT, expr.span, - format!("Expression of type {} must be rooted", t.repr(cx.tcx)).as_slice()); + &format!("Expression of type {} must be rooted", t.repr(cx.tcx))); } } _ => {} diff --git a/components/plugins/utils.rs b/components/plugins/utils.rs index 6c1d7e38268..603aa3569a0 100644 --- a/components/plugins/utils.rs +++ b/components/plugins/utils.rs @@ -22,9 +22,9 @@ pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> // however the more efficient way is to simply reverse the iterators and zip them // which will compare them in reverse until one of them runs out of segments if seg.iter().rev().zip(segments.iter().rev()).all(|(a,b)| a.identifier.as_str() == *b) { - match seg.as_slice().last() { + match seg.last() { Some(&PathSegment {parameters: AngleBracketedParameters(ref a), ..}) => { - Some(a.types.as_slice()) + Some(&a.types) } _ => None } diff --git a/components/profile/mem.rs b/components/profile/mem.rs index 3eb8d3bb72d..522ebe896b4 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -592,7 +592,7 @@ mod system_reporter { }; if looking_for == LookingFor::Segment { // Look for a segment info line. - let cap = match seg_re.captures(line.as_slice()) { + let cap = match seg_re.captures(&line) { Some(cap) => cap, None => continue, }; @@ -617,7 +617,7 @@ mod system_reporter { looking_for = LookingFor::Rss; } else { // Look for an "Rss:" line. - let cap = match rss_re.captures(line.as_slice()) { + let cap = match rss_re.captures(&line) { Some(cap) => cap, None => continue, }; diff --git a/components/script/cors.rs b/components/script/cors.rs index 235ec43f779..a4044a52568 100644 --- a/components/script/cors.rs +++ b/components/script/cors.rs @@ -69,7 +69,7 @@ impl CORSRequest { referer.port() == destination.port() { return Ok(None); // Not cross-origin, proceed with a normal fetch } - match destination.scheme.as_slice() { + match &*destination.scheme { // TODO: If the request's same origin data url flag is set (which isn't the case for XHR) // we can fetch a data URL normally. about:blank can also be fetched by XHR "http" | "https" => { @@ -221,7 +221,7 @@ impl CORSRequest { // Substeps 1-3 (parsing rules: https://fetch.spec.whatwg.org/#http-new-header-syntax) let methods_substep4 = [self.method.clone()]; let mut methods = match response.headers.get() { - Some(&AccessControlAllowMethods(ref v)) => v.as_slice(), + Some(&AccessControlAllowMethods(ref v)) => &**v, _ => return error }; let headers = match response.headers.get() { @@ -420,7 +420,7 @@ impl CORSCache { fn is_simple_header(h: &HeaderView) -> bool { //FIXME: use h.is::<HeaderType>() when AcceptLanguage and //ContentLanguage headers exist - match h.name().to_ascii_lowercase().as_slice() { + match &*h.name().to_ascii_lowercase() { "accept" | "accept-language" | "content-language" => true, "content-type" => match h.value() { Some(&ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) | diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index f41f2feaad2..cfacc639054 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -1019,9 +1019,9 @@ pub mod longhands { try!(dest.write_str(" ")); } first = false; - try!(Token::QuotedString(pair.0.as_slice().into_cow()).to_css(dest)); + try!(Token::QuotedString((*pair.0).into_cow()).to_css(dest)); try!(dest.write_str(" ")); - try!(Token::QuotedString(pair.1.as_slice().into_cow()).to_css(dest)); + try!(Token::QuotedString((*pair.1).into_cow()).to_css(dest)); } Ok(()) } @@ -1381,12 +1381,10 @@ pub mod longhands { if let Ok(value) = input.try(|input| { match input.next() { Err(_) => Err(()), - Ok(Token::Ident(ref ident)) if ident.as_slice() - .eq_ignore_ascii_case("cover") => { + Ok(Token::Ident(ref ident)) if ident.eq_ignore_ascii_case("cover") => { Ok(SpecifiedValue::Cover) } - Ok(Token::Ident(ref ident)) if ident.as_slice() - .eq_ignore_ascii_case("contain") => { + Ok(Token::Ident(ref ident)) if ident.eq_ignore_ascii_case("contain") => { Ok(SpecifiedValue::Contain) } Ok(_) => Err(()), diff --git a/components/style/values.rs b/components/style/values.rs index 80801af930a..3d724829be0 100644 --- a/components/style/values.rs +++ b/components/style/values.rs @@ -888,7 +888,7 @@ pub mod specified { pub fn parse(input: &mut Parser) -> Result<Time,()> { match input.next() { Ok(Token::Dimension(ref value, ref unit)) => { - Time::parse_dimension(value.value, unit.as_slice()) + Time::parse_dimension(value.value, &unit) } _ => Err(()), } diff --git a/components/util/namespace.rs b/components/util/namespace.rs index c138a29706a..03a1513ca89 100644 --- a/components/util/namespace.rs +++ b/components/util/namespace.rs @@ -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)), } } diff --git a/components/util/opts.rs b/components/util/opts.rs index 388ee9ce70a..aaca57729cc 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -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 { diff --git a/components/util/str.rs b/components/util/str.rs index 8f3ee5cb541..e6987f2f809 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -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 } } |