Skip to main content

CoverageResult

Struct CoverageResult 

Source
pub struct CoverageResult {
    pub name: String,
    pub version: String,
    pub line_pct: f64,
    pub function_pct: f64,
    pub region_pct: f64,
    pub total_lines: u64,
    pub covered_lines: u64,
}
Expand description

Result of a coverage run.

Fields§

§name: String

Crate name.

§version: String

Crate version.

§line_pct: f64

Percentage of executable lines that were exercised by tests.

§function_pct: f64

Percentage of functions that were called by tests.

§region_pct: f64

Percentage of regions (branch points) that were exercised.

§total_lines: u64

Total executable lines in the crate.

§covered_lines: u64

Lines that were exercised at least once.

Implementations§

Source§

impl CoverageResult

Source

pub fn into_check_result(self, threshold: CoverageThreshold) -> CheckResult

Convert this result into a CheckResult against the given threshold.

Examples found in repository?
examples/basic.rs (line 16)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let run = CoverageRun::new("example", "0.1.0");
9    let result = run.execute()?;
10
11    println!("Line coverage:     {:.2}%", result.line_pct);
12    println!("Function coverage: {:.2}%", result.function_pct);
13    println!("Region coverage:   {:.2}%", result.region_pct);
14
15    let threshold = CoverageThreshold::min_line_pct(80.0);
16    let check = result.into_check_result(threshold);
17    println!("\nVerdict: {:?}", check.verdict);
18    if let Some(d) = check.detail {
19        println!("Detail:  {d}");
20    }
21    Ok(())
22}

Trait Implementations§

Source§

impl Clone for CoverageResult

Source§

fn clone(&self) -> CoverageResult

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 CoverageResult

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.