pub struct Comment<'a> { /* private fields */ }Expand description
A validated comment: the text without the outer parentheses, and the deepest nesting reached.
§Examples
use parse_net::{text::parse_comment, Limits};
let (c, _) = parse_comment(b"(a(b))", &Limits::DEFAULT)?;
assert_eq!((c.raw(), c.max_depth()), (&b"a(b)"[..], 2));Implementations§
Source§impl<'a> Comment<'a>
impl<'a> Comment<'a>
Sourcepub const fn raw(&self) -> &'a [u8] ⓘ
pub const fn raw(&self) -> &'a [u8] ⓘ
The text between the outer parentheses, as sent.
§Examples
use parse_net::{text::parse_comment, Limits};
let (c, _) = parse_comment(b"(gzip; level 9) x", &Limits::DEFAULT)?;
assert_eq!(c.raw(), b"gzip; level 9");Sourcepub const fn max_depth(&self) -> u8
pub const fn max_depth(&self) -> u8
The deepest nesting reached: 1 for (a), 2 for (a(b)).
§Examples
use parse_net::{text::parse_comment, Limits};
assert_eq!(parse_comment(b"(a)", &Limits::DEFAULT)?.0.max_depth(), 1);
assert_eq!(parse_comment(b"(a(b(c)) d)", &Limits::DEFAULT)?.0.max_depth(), 3);Trait Implementations§
impl<'a> Copy for Comment<'a>
impl<'a> Eq for Comment<'a>
impl<'a> StructuralPartialEq for Comment<'a>
Auto Trait Implementations§
impl<'a> Freeze for Comment<'a>
impl<'a> RefUnwindSafe for Comment<'a>
impl<'a> Send for Comment<'a>
impl<'a> Sync for Comment<'a>
impl<'a> Unpin for Comment<'a>
impl<'a> UnsafeUnpin for Comment<'a>
impl<'a> UnwindSafe for Comment<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more