pub struct CodeBlock {
pub index: usize,
pub lang: String,
pub tags: Vec<String>,
pub code: String,
pub line: usize,
pub close_line: usize,
pub ticks: usize,
}Expand description
One fenced code block.
Fields§
§index: usize0-based ordinal among ALL fenced blocks in the file.
lang: StringFirst token of the info string (“rust”, “text”, “console”, …).
Remaining info-string tokens (“no_run”, “ignore”, “capture-output”, …).
code: String§line: usize1-based line of the opening fence.
close_line: usize1-based line of the closing fence.
ticks: usizeBacktick count of the opening fence.
Implementations§
Source§impl CodeBlock
impl CodeBlock
pub fn has_tag(&self, tag: &str) -> bool
Sourcepub fn is_testable_rust(&self) -> bool
pub fn is_testable_rust(&self) -> bool
A rust block that should become a generated test.
pub fn is_capture(&self) -> bool
Sourcepub fn feature_tag(&self) -> Option<&str>
pub fn feature_tag(&self) -> Option<&str>
Raw value of a feature=NAME tag: the cargo feature the generated test
is gated behind (for blocks exercising feature-gated API). Callers that
want the individual features want Self::feature_list instead.
Sourcepub fn feature_list(&self) -> Vec<&str>
pub fn feature_list(&self) -> Vec<&str>
Individual features of a feature= tag — one, or several
comma-separated with no spaces (feature=risk,polygon; a space
would split into a separate fence tag) when a block needs more than one
feature to compile. Empty when the block has no feature= tag; scan
rejects a tag whose value names no feature.
Sourcepub fn feature_cfg(&self) -> Option<String>
pub fn feature_cfg(&self) -> Option<String>
The cfg predicate gating this block, or None when it has no
feature= tag. Several features become an all(...) — every listed
feature must be on for the block to compile.
Sourcepub fn mock_tag(&self) -> Option<(&str, &str)>
pub fn mock_tag(&self) -> Option<(&str, &str)>
(name, arg) from a mock=NAME or mock=NAME(ARG) tag — the name of
a #[soothfast::mock_seam] fn this block calls via
soothfast::mock::activate(name, arg), and its arg ("" when
omitted). Requires an accompanying feature= tag; enforced in scan.
Sourcepub fn covers_tag(&self) -> Option<&str>
pub fn covers_tag(&self) -> Option<&str>
Raw value of a covers=path::to::item tag — one item, or several
comma-separated with no spaces (covers=a::b,a::c; a space
would split into a separate fence tag) when a single example
demonstrates more than one measured/bound item. A claim or bind for
any listed item renders attached to this block instead of as a
standalone chip. Callers that need the individual items should split
the value on , and trim.