1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3
4use super::Comment;
5// This is a helper struct used to properly deserialize referential
6// JSON comments which are single continous String, into a vec of
7// content slices.
8#[derive(Debug, PartialEq, Clone)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10#[cfg_attr(feature = "serde", serde(untagged))]
11pub enum CommentDef<S> {
12 Single { content: S },
13 Multi { content: Vec<S> },
14}
15
16impl<'s, S> From<CommentDef<S>> for Comment<S> {
17 fn from(input: CommentDef<S>) -> Self {
18 match input {
19 CommentDef::Single { content: S } => Self {
20 content: vec![content],
21 },
22 CommentDef::Multi { content: Vec } => Self { content },
23 }
24 }
25}
26