1#[allow(unused_imports)]
4use super::*;
5use crate::compat::{Comment, Name};
6
7#[derive(Debug, Default, PartialEq, Eq, Hash, Clone)]
9pub struct Node {
10 name: Name,
11 comment: Option<Comment>,
12}
13impl Node {
14 #[inline]
16 pub(crate) fn new(name: Name) -> Self {
17 Self {
18 name,
19 comment: None,
20 }
21 }
22
23 #[inline]
25 #[cfg(feature = "std")]
26 pub(crate) fn with_comment(name: Name, comment: Option<Comment>) -> Self {
27 Self { name, comment }
28 }
29
30 #[inline]
32 #[must_use = "return value should be used"]
33 pub fn name(&self) -> &str {
34 self.name.as_str()
35 }
36
37 #[inline]
39 #[must_use = "return value should be used"]
40 pub fn comment(&self) -> Option<&str> {
41 self.comment.as_ref().map(|c| c.as_str())
42 }
43
44 #[inline]
46 pub(crate) fn set_comment(&mut self, comment: Comment) {
47 self.comment = Some(comment);
48 }
49}