diff --git a/lib/src/http/raw_str.rs b/lib/src/http/raw_str.rs index 652adbb5..a4828963 100644 --- a/lib/src/http/raw_str.rs +++ b/lib/src/http/raw_str.rs @@ -46,6 +46,7 @@ use http::uncased::UncasedStr; /// /// [`FromParam`]: /rocket/request/trait.FromParam.html /// [`FromFormValue`]: /rocket/request/trait.FromFormValue.html +#[repr(C)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct RawStr(str); @@ -276,7 +277,7 @@ impl RawStr { impl<'a> From<&'a str> for &'a RawStr { #[inline(always)] fn from(string: &'a str) -> &'a RawStr { - unsafe { ::std::mem::transmute(string) } + unsafe { &*(string as *const str as *const RawStr) } } } diff --git a/lib/src/http/uncased.rs b/lib/src/http/uncased.rs index d8ac4c38..5cfb76ab 100644 --- a/lib/src/http/uncased.rs +++ b/lib/src/http/uncased.rs @@ -18,6 +18,7 @@ use std::fmt; /// /// let ascii_ref: &UncasedStr = "Hello, world!".into(); /// ``` +#[repr(C)] #[derive(Debug)] pub struct UncasedStr(str);