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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
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.