Struct plantuml_parser::IncludeToken
source · pub struct IncludeToken { /* private fields */ }
Expand description
A token sequence with IncludeSpecifierToken
that is around the include keyword. (like "!include foo.puml"
or "!include bar.iuml!buz"
, "!include_many foo.puml"
or "!include_many bar.iuml!buz"
.)
!include [include specifier]
!include_many [include specifier]
!include_once [include specifier]
The above include specifier
is parsed by IncludeSpecifierToken
.
Examples
use plantuml_parser::{IncludeKind, IncludeToken, ParseContainer};
let input = "!include foo.puml rest";
let (rest, (raws, token)) = IncludeToken::parse(input.into())?;
let combined_raw: ParseContainer = raws.into();
assert_eq!(rest, " rest");
assert_eq!(combined_raw, "!include foo.puml");
assert_eq!(token.filepath(), "foo.puml");
assert_eq!(token.index(), None);
assert_eq!(token.id(), None);
assert_eq!(token.kind(), &IncludeKind::Include);
let input = "!include_many bar.iuml!1 rest";
let (rest, (raws, token)) = IncludeToken::parse(input.into())?;
let combined_raw: ParseContainer = raws.into();
assert_eq!(rest, " rest");
assert_eq!(combined_raw, "!include_many bar.iuml!1");
assert_eq!(token.filepath(), "bar.iuml");
assert_eq!(token.index(), Some(1));
assert_eq!(token.id(), Some("1"));
assert_eq!(token.kind(), &IncludeKind::IncludeMany);
let input = "!include_once baz.txt!qux rest";
let (rest, (raws, token)) = IncludeToken::parse(input.into())?;
let combined_raw: ParseContainer = raws.into();
assert_eq!(rest, " rest");
assert_eq!(combined_raw, "!include_once baz.txt!qux");
assert_eq!(token.filepath(), "baz.txt");
assert_eq!(token.index(), None);
assert_eq!(token.id(), Some("qux"));
assert_eq!(token.kind(), &IncludeKind::IncludeOnce);
Implementations§
source§impl IncludeToken
impl IncludeToken
sourcepub fn parse(input: ParseContainer) -> ParseResult<Self>
pub fn parse(input: ParseContainer) -> ParseResult<Self>
Tries to parse IncludeToken
. (e.g. "!include foo.puml"
, "!include bar.iuml!buz"
.)
sourcepub fn kind(&self) -> &IncludeKind
pub fn kind(&self) -> &IncludeKind
Returns the IncludeKind
of include keywords.
Methods from Deref<Target = IncludeSpecifierToken>§
Trait Implementations§
source§impl Clone for IncludeToken
impl Clone for IncludeToken
source§fn clone(&self) -> IncludeToken
fn clone(&self) -> IncludeToken
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for IncludeToken
impl Debug for IncludeToken
Auto Trait Implementations§
impl RefUnwindSafe for IncludeToken
impl Send for IncludeToken
impl Sync for IncludeToken
impl Unpin for IncludeToken
impl UnwindSafe for IncludeToken
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