chore(all): Move downcasting to a stable implementation.

This commit is contained in:
Jonathan Reem
2015-04-02 13:26:47 -07:00
parent 3dc8e7d6ff
commit 320d10d50d
4 changed files with 20 additions and 17 deletions

View File

@@ -6,14 +6,12 @@
//! are already provided, such as `Host`, `ContentType`, `UserAgent`, and others.
use std::any::Any;
use std::borrow::{Cow, ToOwned};
use std::fmt;
use std::collections::HashMap;
use std::collections::hash_map::{Iter, Entry};
use std::iter::{FromIterator, IntoIterator};
use std::raw::TraitObject;
use std::{mem, raw};
use std::{mem, fmt};
use httparse;
use {httparse, traitobject};
use unicase::UniCase;
use self::internals::Item;
@@ -76,12 +74,12 @@ impl<T: HeaderFormat + Send + Sync + Clone> HeaderClone for T {
impl HeaderFormat + Send + Sync {
#[inline]
unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &T {
mem::transmute(mem::transmute::<&HeaderFormat, raw::TraitObject>(self).data)
mem::transmute(traitobject::data(self))
}
#[inline]
unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &mut T {
mem::transmute(mem::transmute::<&mut HeaderFormat, raw::TraitObject>(self).data)
mem::transmute(traitobject::data_mut(self))
}
}