pub struct FeatureId<'g> { /* private fields */ }
Expand description
An identifier for a (package, feature) pair in a feature graph.
Returned by various methods on FeatureGraph
and FeatureQuery
.
From
impls are available for (&'g PackageId, &'g str)
and (&'g PackageId, Option<&'g str>)
tuples.
Implementations§
Source§impl<'g> FeatureId<'g>
impl<'g> FeatureId<'g>
Sourcepub fn new(package_id: &'g PackageId, label: FeatureLabel<'g>) -> Self
pub fn new(package_id: &'g PackageId, label: FeatureLabel<'g>) -> Self
Creates a new FeatureId
with the given PackageId
and FeatureLabel
.
Sourcepub fn named(package_id: &'g PackageId, feature_name: &'g str) -> Self
pub fn named(package_id: &'g PackageId, feature_name: &'g str) -> Self
Creates a new FeatureId
representing a named feature in the [features]
section,
or an implicit named feature created by an optional dependency.
Sourcepub fn optional_dependency(package_id: &'g PackageId, dep_name: &'g str) -> Self
pub fn optional_dependency(package_id: &'g PackageId, dep_name: &'g str) -> Self
Creates a new FeatureId
representing an optional dependency.
Sourcepub fn base(package_id: &'g PackageId) -> Self
pub fn base(package_id: &'g PackageId) -> Self
Creates a new FeatureId
representing the base feature for a package.
Sourcepub fn package_id(&self) -> &'g PackageId
pub fn package_id(&self) -> &'g PackageId
Returns the package ID.
Sourcepub fn label(&self) -> FeatureLabel<'g>
pub fn label(&self) -> FeatureLabel<'g>
Returns the FeatureLabel
associated with the feature.
Sourcepub fn is_optional_dependency(self) -> bool
pub fn is_optional_dependency(self) -> bool
Returns true if this is an optional dependency.
Trait Implementations§
Source§impl<'g> Display for FeatureId<'g>
impl<'g> Display for FeatureId<'g>
The Display
impl prints out:
{package-id}/[base]
for base features.{package-id}/feature-name
for named features.{package-id}/dep:dep-name
for optional dependencies.
§Examples
use guppy::PackageId;
use guppy::graph::feature::FeatureId;
let package_id = PackageId::new("region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)");
assert_eq!(
format!("{}", FeatureId::base(&package_id)),
"region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)/[base]"
);
assert_eq!(
format!("{}", FeatureId::named(&package_id, "foo")),
"region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)/foo"
);
assert_eq!(
format!("{}", FeatureId::optional_dependency(&package_id, "bar")),
"region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)/dep:bar"
);
Source§impl<'g> From<(&'g PackageId, FeatureLabel<'g>)> for FeatureId<'g>
impl<'g> From<(&'g PackageId, FeatureLabel<'g>)> for FeatureId<'g>
Source§fn from((package_id, label): (&'g PackageId, FeatureLabel<'g>)) -> Self
fn from((package_id, label): (&'g PackageId, FeatureLabel<'g>)) -> Self
Converts to this type from the input type.
Source§impl<'g> Ord for FeatureId<'g>
impl<'g> Ord for FeatureId<'g>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'g> PartialOrd for FeatureId<'g>
impl<'g> PartialOrd for FeatureId<'g>
impl<'g> Copy for FeatureId<'g>
impl<'g> Eq for FeatureId<'g>
impl<'g> StructuralPartialEq for FeatureId<'g>
Auto Trait Implementations§
impl<'g> Freeze for FeatureId<'g>
impl<'g> RefUnwindSafe for FeatureId<'g>
impl<'g> Send for FeatureId<'g>
impl<'g> Sync for FeatureId<'g>
impl<'g> Unpin for FeatureId<'g>
impl<'g> UnwindSafe for FeatureId<'g>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.