Skip to main content

FeatureLinkVisitor

Trait FeatureLinkVisitor 

Source
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§

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 Required link as soon as weak is reached. It offers the Optional link only once dep:foo is activated, which may be at an unrelated point later in the traversal.
  • A reverse query offers both links (Required first) as soon as foo/std is reached. Reverse queries don’t try to model when foo is activated.

Trait Implementations§

Source§

impl<'g> FeatureLinkVisitor<'g> for Box<dyn FeatureLinkVisitor<'g> + '_>

Returns true if this conditional link should be followed during a resolve operation. Read more
Source§

impl<'g> FeatureLinkVisitor<'g> for &mut dyn FeatureLinkVisitor<'g>

Returns true if this conditional link should be followed during a resolve operation. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'g, T> FeatureLinkVisitor<'g> for &mut T
where T: FeatureLinkVisitor<'g>,

Source§

impl<'g> FeatureLinkVisitor<'g> for Box<dyn FeatureLinkVisitor<'g> + '_>

Implementors§

Source§

impl<'g> FeatureLinkVisitor<'g> for &mut dyn FeatureLinkVisitor<'g>