java_lang/tree/node/
documentation_comment.rs

1use std::{
2    borrow::Cow,
3    fmt::{Display, Formatter, Result as FmtResult}
4};
5
6/// Java中的文档注释
7#[derive(Debug, PartialEq)]
8pub struct DocumentationComment<'a>(Cow<'a, str>);
9
10impl<'a> Display for DocumentationComment<'a> {
11    fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
12        write!(f, "/**{}*/\n", self.0)
13    }
14}
15
16impl<'a> From<&'a str> for DocumentationComment<'a> {
17    fn from(value: &'a str) -> Self {
18        Self (value.into())
19    }
20}
21
22impl<'a> From<String> for DocumentationComment<'a> {
23    fn from(value: String) -> Self {
24        Self(value.into())
25    }
26}