Skip to content

Commit f4da514

Browse files
committed
doc(cargo_compile): more on compile filter
1 parent e6d90b4 commit f4da514

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/cargo/ops/cargo_compile/compile_filter.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Filters and their rules to select which Cargo targets will be built.
2+
13
use crate::core::compiler::CompileMode;
24
use crate::core::{Target, TargetKind};
35
use crate::util::restricted_names::is_glob_pattern;
@@ -27,7 +29,10 @@ pub enum FilterRule {
2729
///
2830
/// The actual filter process happens inside [`generate_targets`].
2931
///
32+
/// Not to be confused with [`Packages`], which opts in packages to be built.
33+
///
3034
/// [`generate_targets`]: super::generate_targets
35+
/// [`Packages`]: crate::ops::Packages
3136
#[derive(Debug)]
3237
pub enum CompileFilter {
3338
/// The default set of Cargo targets.
@@ -56,17 +61,25 @@ impl FilterRule {
5661
}
5762
}
5863

64+
/// Creates a filter with no rule.
65+
///
66+
/// In the current Cargo implementation, filter without a rule implies
67+
/// Cargo will follows the default behaviour to filter targets.
5968
pub fn none() -> FilterRule {
6069
FilterRule::Just(Vec::new())
6170
}
6271

72+
/// Checks if a target definition matches this filter rule.
6373
fn matches(&self, target: &Target) -> bool {
6474
match *self {
6575
FilterRule::All => true,
6676
FilterRule::Just(ref targets) => targets.iter().any(|x| *x == target.name()),
6777
}
6878
}
6979

80+
/// Check if a filter is specific.
81+
///
82+
/// Only filters without rules are considered as not specific.
7083
fn is_specific(&self) -> bool {
7184
match *self {
7285
FilterRule::All => true,
@@ -81,6 +94,7 @@ impl FilterRule {
8194
}
8295
}
8396

97+
/// Checks if any specified target name contains glob patterns.
8498
pub(crate) fn contains_glob_patterns(&self) -> bool {
8599
match self {
86100
FilterRule::All => false,
@@ -274,6 +288,7 @@ impl CompileFilter {
274288
)
275289
}
276290

291+
/// Checks if any specified target name contains glob patterns.
277292
pub(crate) fn contains_glob_patterns(&self) -> bool {
278293
match self {
279294
CompileFilter::Default { .. } => false,

src/cargo/ops/cargo_compile/packages.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! See [`Packages`].
2+
13
use std::collections::BTreeSet;
24

35
use crate::core::Package;

0 commit comments

Comments
 (0)