Struct Doc
#[repr(transparent)]pub struct Doc(str);Expand description
Doc comment of a declaration, a field or an enum variant.
The text contains the lines of the comment without the leading #,
separated by \n. An empty text is a comment of one empty line. Other
line breaks are rejected: written as IDL text, they would end the comment
and turn the rest of the line into a declaration.
use varlet_idl::Doc;
const DOC: &Doc = Doc::from_static("Adds numbers.\n\nIt never fails.");
assert_eq!(
DOC.lines().collect::<Vec<_>>(),
["Adds numbers.", "", "It never fails."]
);
assert!(Doc::new("Adds numbers.\rmethod Evil() -> ()").is_err());Tuple Fields§
§0: strImplementations§
§impl Doc
impl Doc
pub const fn from_static(text: &'static str) -> &'static Self
pub const fn from_static(text: &'static str) -> &'static Self
pub fn lines(&self) -> Split<'_, char> ⓘ
pub fn lines(&self) -> Split<'_, char> ⓘ
Returns the lines of the doc comment.
There is always at least one line.
pub const fn new(text: &str) -> Result<&Self, InvalidDoc>
pub const fn new(text: &str) -> Result<&Self, InvalidDoc>
Checks that text separates lines with \n only.
§Errors
Returns the position of the first other line break: \r, U+2028 or
U+2029.
const fn check(rest: &[u8]) -> Result<(), InvalidDoc>
const fn check(rest: &[u8]) -> Result<(), InvalidDoc>
Checks the bytes of a text for line breaks other than \n.