mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-07-24 01:55:55 +00:00
Remove unsafe Deserialize impl for CStr
See also https://github.com/rust-lang/rust/issues/40248
This commit is contained in:
@@ -297,19 +297,6 @@ impl Deserialize for String {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl Deserialize for Box<CStr> {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where D: Deserializer
|
|
||||||
{
|
|
||||||
use std::mem;
|
|
||||||
let s = try!(CString::deserialize(deserializer));
|
|
||||||
let slice = s.into_bytes_with_nul().into_boxed_slice();
|
|
||||||
Ok(unsafe { mem::transmute::<Box<[u8]>, Box<CStr>>(slice) })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl Deserialize for CString {
|
impl Deserialize for CString {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<CString, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<CString, D::Error>
|
||||||
|
|||||||
Reference in New Issue
Block a user