use serde::ser::SerializeMap;
use serde::{Serialize, Serializer};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Merge<T>(pub T);
impl<T> Merge<T> {
pub fn new(value: T) -> Self {
Self(value)
}
}
impl<T: Serialize> Serialize for Merge<T> {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
let mut map = s.serialize_map(Some(1))?;
map.serialize_entry(super::MERGE_SENTINEL, &self.0)?;
map.end()
}
}
#[cfg(feature = "ts")]
impl<T: ts_rs::TS> ts_rs::TS for Merge<T> {
type WithoutGenerics = <T as ts_rs::TS>::WithoutGenerics;
type OptionInnerType = <T as ts_rs::TS>::OptionInnerType;
fn ident() -> String {
<T as ts_rs::TS>::ident()
}
fn name() -> String {
<T as ts_rs::TS>::name()
}
fn inline() -> String {
<T as ts_rs::TS>::inline()
}
fn inline_flattened() -> String {
<T as ts_rs::TS>::inline_flattened()
}
fn visit_dependencies(v: &mut impl ts_rs::TypeVisitor)
where
Self: 'static,
{
<T as ts_rs::TS>::visit_dependencies(v);
}
fn visit_generics(v: &mut impl ts_rs::TypeVisitor)
where
Self: 'static,
{
<T as ts_rs::TS>::visit_generics(v);
}
fn decl() -> String {
<T as ts_rs::TS>::decl()
}
fn decl_concrete() -> String {
<T as ts_rs::TS>::decl_concrete()
}
fn output_path() -> Option<std::path::PathBuf> {
<T as ts_rs::TS>::output_path()
}
}