paperclip_core/
im.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! Interior mutability stuff.

#[cfg(feature = "v2")]
use crate::v2::models::Resolvable;
#[cfg(feature = "v2")]
use serde::{Serialize, Serializer};

#[cfg(feature = "v2")]
impl<T> Serialize for Resolvable<T>
where
    T: Serialize,
{
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
        match self {
            Resolvable::Raw(s) => s.serialize(serializer),
            Resolvable::Resolved { new, .. } => new.serialize(serializer),
        }
    }
}