diff --git a/src/header/mod.rs b/src/header/mod.rs index 2f32c37d76..c81de30ec8 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -75,7 +75,7 @@ impl HeaderClone for T { } } -impl HeaderFormat { +impl HeaderFormat + Send + Sync { #[inline] unsafe fn downcast_ref_unchecked(&self) -> &T { mem::transmute(mem::transmute::<&HeaderFormat, raw::TraitObject>(self).data) diff --git a/src/net.rs b/src/net.rs index c3c53f692d..3765e9caf7 100644 --- a/src/net.rs +++ b/src/net.rs @@ -97,7 +97,7 @@ impl Clone for Box { fn clone(&self) -> Box { self.clone_box() } } -impl NetworkStream { +impl NetworkStream + Send { unsafe fn downcast_ref_unchecked(&self) -> &T { mem::transmute(mem::transmute::<&NetworkStream, raw::TraitObject>(self).data) @@ -108,13 +108,13 @@ impl NetworkStream { raw::TraitObject>(self).data) } - unsafe fn downcast_unchecked(self: Box) -> Box { - mem::transmute(mem::transmute::, + unsafe fn downcast_unchecked(self: Box) -> Box { + mem::transmute(mem::transmute::, raw::TraitObject>(self).data) } } -impl NetworkStream { +impl NetworkStream + Send { /// Is the underlying type in this trait object a T? #[inline] pub fn is(&self) -> bool { @@ -143,8 +143,8 @@ impl NetworkStream { } /// If the underlying type is T, extract it. - pub fn downcast(self: Box) - -> Result, Box> { + pub fn downcast(self: Box) + -> Result, Box> { if self.is::() { Ok(unsafe { self.downcast_unchecked() }) } else {