Merge pull request #128 from reem/find-equiv

Rust update
This commit is contained in:
Sean McArthur
2014-11-19 15:28:43 -08:00
2 changed files with 15 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ extern crate hyper;
extern crate test;
use std::fmt::{mod, Show};
use std::from_str::from_str;
use std::str::from_str;
use std::io::{IoResult, MemReader};
use std::io::net::ip::{SocketAddr, ToSocketAddr};
use std::os;
@@ -55,7 +55,7 @@ impl Writer for MockStream {
#[bench]
fn bench_mock_curl(b: &mut test::Bencher) {
let mut cwd = os::getcwd();
let mut cwd = os::getcwd().unwrap();
cwd.push("README.md");
let s = format!("file://{}", cwd.container_as_str().unwrap());
let url = s.as_slice();

View File

@@ -145,7 +145,10 @@ impl Headers {
/// let raw_content_type = headers.get_raw("content-type");
/// ```
pub fn get_raw(&self, name: &str) -> Option<&[Vec<u8>]> {
self.data.find_equiv(&CaseInsensitive(name)).and_then(|item| {
self.data
// FIXME(reem): Find a better way to do this lookup without find_equiv.
.get(&CaseInsensitive(Slice(unsafe { mem::transmute::<&str, &str>(name) })))
.and_then(|item| {
let lock = item.read();
if let Some(ref raw) = lock.raw {
return unsafe { mem::transmute(Some(raw[])) };