pub trait FeatureLinkVisitor<'g> {
// Required method
fn visit_link(
&mut self,
cx: &FeatureLinkContext<'g>,
link: ConditionalLink<'g>,
) -> bool;
}Expand description
Represents whether a particular link within a feature graph should be followed during a resolve operation.
Required Methods§
Sourcefn visit_link(
&mut self,
cx: &FeatureLinkContext<'g>,
link: ConditionalLink<'g>,
) -> bool
fn visit_link( &mut self, cx: &FeatureLinkContext<'g>, link: ConditionalLink<'g>, ) -> bool
Returns true if this conditional link should be followed during a resolve operation.
§Weak dependency features
Most links are visited at most once per resolve. The exception is a weak
dependency feature (dep?/feature) on a dependency with both required
and optional declarations. For example:
[dependencies]
foo = { version = "1" }
[build-dependencies]
foo = { version = "1", optional = true }
[features]
weak = ["foo?/std"]Cargo applies foo?/std to each declaration of foo separately, so
this method can be called twice for the link from weak to foo/std:
- First with a link covering the required declarations of
foo: here,[dependencies]. - Then with a link covering the optional ones: here,
[build-dependencies].
Both links have the same endpoints. Use
ConditionalLink::declarations to tell them apart. The feature graph
has one edge for the two links, and that edge is followed if this method
returns true for either of them.
A visitor that keeps state for each link, such as a count of visits, should take this into account.
When the two links are offered depends on the query’s direction:
- A forward query offers the
Requiredlink as soon asweakis reached. It offers theOptionallink only oncedep:foois activated, which may be at an unrelated point later in the traversal. - A reverse query offers both links (
Requiredfirst) as soon asfoo/stdis reached. Reverse queries don’t try to model whenfoois activated.
Trait Implementations§
Source§impl<'g> FeatureLinkVisitor<'g> for Box<dyn FeatureLinkVisitor<'g> + '_>
impl<'g> FeatureLinkVisitor<'g> for Box<dyn FeatureLinkVisitor<'g> + '_>
Source§fn visit_link(
&mut self,
cx: &FeatureLinkContext<'g>,
link: ConditionalLink<'g>,
) -> bool
fn visit_link( &mut self, cx: &FeatureLinkContext<'g>, link: ConditionalLink<'g>, ) -> bool
Source§impl<'g> FeatureLinkVisitor<'g> for &mut dyn FeatureLinkVisitor<'g>
impl<'g> FeatureLinkVisitor<'g> for &mut dyn FeatureLinkVisitor<'g>
Source§fn visit_link(
&mut self,
cx: &FeatureLinkContext<'g>,
link: ConditionalLink<'g>,
) -> bool
fn visit_link( &mut self, cx: &FeatureLinkContext<'g>, link: ConditionalLink<'g>, ) -> bool
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".