(fix) Replace find_equiv with a lifetime transmute.

This commit is contained in:
Jonathan Reem
2014-11-19 14:52:49 -08:00
parent 5e92d826d4
commit dbfcd1ecfc

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[])) };