Debian Codegraph @

src/ast/helper.rs

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