1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! Utilities for de-/serialization with `erased_serde`.

use serde;
use erased_serde;


/// A serializable type that serializes the enclosed value using `erased_serde`.
pub struct SerializeErased<'b, T: ?Sized + 'b>(pub &'b T);

impl<'b, T> serde::Serialize for SerializeErased<'b, T>
where
    T: erased_serde::Serialize + ?Sized
{
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        erased_serde::serialize(self.0, serializer)
    }
}