Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an `Unserializable` type to utils #9379

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

ipc: Improve `Unserializable` debugging, and derive Eq and PartialEq

when appropiate
  • Loading branch information
emilio committed Jan 19, 2016
commit 1b603e2ac50c2e8dbbbd58ff3edfff1bf2f0282c
@@ -9,6 +9,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::any::{Any, TypeId};
use std::collections::HashMap;
use std::fmt;
use std::intrinsics::type_name;
use std::io::{Error, ErrorKind};
use std::marker::Reflect;
use std::mem;
@@ -205,15 +206,23 @@ impl<T: Clone> Clone for Unserializable<T> {

impl<T: Copy> Copy for Unserializable<T> {}

impl<T: PartialEq> PartialEq for Unserializable<T> {
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
}

impl<T: Eq> Eq for Unserializable<T> {}

impl<T> Serialize for Unserializable<T> {
fn serialize<S>(&self, _: &mut S) -> Result<(), S::Error> where S: Serializer {
panic!("Can't serialize a `Unserializable` struct");
panic!("Can't serialize a `Unserializable({})` struct", unsafe { type_name::<T>() });
}
}

impl<T> Deserialize for Unserializable<T> {
fn deserialize<D>(_: &mut D) -> Result<Unserializable<T>, D::Error> where D: Deserializer {
panic!("Can't deserialize a `Unserializable` struct");
panic!("Can't deserialize a `Unserializable({})` struct", unsafe { type_name::<T>() });
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.