Struct lcov::filter::line_num::LineNum [−][src]
pub struct LineNum { /* fields omitted */ }
Expand description
A Section
filter that extracts only the records related to the specified line numbers.
This filter is useful for measuring the coverage of the part changed by a specific commit.
Examples
use lcov::Report;
use lcov::filter::{FilterMap, LineNum};
use std::collections::HashMap;
use std::path::PathBuf;
use std::iter::FromIterator;
// Creates a `Report` from file.
let mut report = Report::from_file("report.info")?;
// Setup the filter.
let mut filter = HashMap::new();
filter.insert(
PathBuf::from("foo.rs"),
LineNum::from_iter([0..5, 10..20].iter().cloned())
);
// Filters the coverage information.
report.sections.filter_map(|(key, mut value)| {
filter.get(&key.source_file).and_then(|filter| {
filter.apply(&mut value);
if value.is_empty() { None } else { Some((key, value)) }
})
});
Implementations
Creates an empty filter.
An empty filter filters out all records.
Examples
use lcov::filter::line_num::LineNum;
let filter = LineNum::new();
Inserts a range of lines that those coverage information should be yielded.
Examples
use lcov::filter::line_num::LineNum;
let mut filter = LineNum::new();
filter.insert(3..4);
filter.insert(7..10);
Applies the filter to section
.
Examples
use lcov::Report;
use lcov::filter::{FilterMap, LineNum};
use std::collections::HashMap;
use std::path::PathBuf;
use std::iter::FromIterator;
// Creates a `Report` from file.
let mut report = Report::from_file("report.info")?;
// Setup the filter.
let mut filter = HashMap::new();
filter.insert(
PathBuf::from("foo.rs"),
LineNum::from_iter([0..5, 10..20].iter().cloned())
);
// Filters the coverage information.
report.sections.filter_map(|(key, mut value)| {
filter.get(&key.source_file).and_then(|filter| {
filter.apply(&mut value);
if value.is_empty() { None } else { Some((key, value)) }
})
});
Trait Implementations
Extends a collection with the contents of an iterator. Read more
🔬 This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
🔬 This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
Auto Trait Implementations
impl RefUnwindSafe for LineNum
impl UnwindSafe for LineNum
Blanket Implementations
Mutably borrows from an owned value. Read more