(fix) Replace find_equiv with a lifetime transmute.
This commit is contained in:
		| @@ -145,17 +145,20 @@ impl Headers { | |||||||
|     /// let raw_content_type = headers.get_raw("content-type"); |     /// let raw_content_type = headers.get_raw("content-type"); | ||||||
|     /// ``` |     /// ``` | ||||||
|     pub fn get_raw(&self, name: &str) -> Option<&[Vec<u8>]> { |     pub fn get_raw(&self, name: &str) -> Option<&[Vec<u8>]> { | ||||||
|         self.data.find_equiv(&CaseInsensitive(name)).and_then(|item| { |         self.data | ||||||
|             let lock = item.read(); |             // FIXME(reem): Find a better way to do this lookup without find_equiv. | ||||||
|             if let Some(ref raw) = lock.raw { |             .get(&CaseInsensitive(Slice(unsafe { mem::transmute::<&str, &str>(name) }))) | ||||||
|                 return unsafe { mem::transmute(Some(raw[])) }; |             .and_then(|item| { | ||||||
|             } |                 let lock = item.read(); | ||||||
|  |                 if let Some(ref raw) = lock.raw { | ||||||
|  |                     return unsafe { mem::transmute(Some(raw[])) }; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|             let mut lock = item.write(); |                 let mut lock = item.write(); | ||||||
|             let raw = vec![lock.typed.as_ref().unwrap().to_string().into_bytes()]; |                 let raw = vec![lock.typed.as_ref().unwrap().to_string().into_bytes()]; | ||||||
|             lock.raw = Some(raw); |                 lock.raw = Some(raw); | ||||||
|             unsafe { mem::transmute(Some(lock.raw.as_ref().unwrap()[])) } |                 unsafe { mem::transmute(Some(lock.raw.as_ref().unwrap()[])) } | ||||||
|         }) |             }) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// Set the raw value of a header, bypassing any typed headers. |     /// Set the raw value of a header, bypassing any typed headers. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user