Skip to main content

CodeBlock

Struct CodeBlock 

Source
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: usize

0-based ordinal among ALL fenced blocks in the file.

§lang: String

First token of the info string (“rust”, “text”, “console”, …).

§tags: Vec<String>

Remaining info-string tokens (“no_run”, “ignore”, “capture-output”, …).

§code: String§line: usize

1-based line of the opening fence.

§close_line: usize

1-based line of the closing fence.

§ticks: usize

Backtick count of the opening fence.

Implementations§

Source§

impl CodeBlock

Source

pub fn has_tag(&self, tag: &str) -> bool

Source

pub fn is_testable_rust(&self) -> bool

A rust block that should become a generated test.

Source

pub fn is_capture(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for CodeBlock

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodeBlock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.