Struct crates_index::Dependency
source · pub struct Dependency { /* private fields */ }Expand description
A single dependency of a specific crate version
Implementations
sourceimpl Dependency
impl Dependency
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Dependency’s arbitrary nickname (it may be an alias). Use Dependency::crate_name for actual crate name.
sourcepub fn requirement(&self) -> &str
pub fn requirement(&self) -> &str
Semver version pattern
sourcepub fn features(&self) -> &[String]
pub fn features(&self) -> &[String]
Features unconditionally enabled when using this dependency,
in addition to Dependency::has_default_features and features enabled through
parent crate’s feature list.
sourcepub fn is_optional(&self) -> bool
pub fn is_optional(&self) -> bool
If it’s optional, it implies a feature of its Dependency::name, and can be enabled through
the crate’s features.
sourcepub fn has_default_features(&self) -> bool
pub fn has_default_features(&self) -> bool
If true (default), enable default feature of this dependency
sourcepub fn target(&self) -> Option<&str>
pub fn target(&self) -> Option<&str>
This dependency is only used when compiling for this cfg expression
sourcepub fn kind(&self) -> DependencyKind
pub fn kind(&self) -> DependencyKind
Dev or not
sourcepub fn package(&self) -> Option<&str>
pub fn package(&self) -> Option<&str>
Set if dependency’s crate name is different from the name (alias)
sourcepub fn crate_name(&self) -> &str
pub fn crate_name(&self) -> &str
Returns the name of the crate providing the dependency.
This is equivalent to name() unless self.package()
is not None, in which case it’s equal to self.package().
Basically, you can define a dependency in your Cargo.toml
like this:
serde_lib = {version = "1", package = "serde"}…which means that it uses the crate serde but imports
it under the name serde_lib.
Trait Implementations
sourceimpl Clone for Dependency
impl Clone for Dependency
sourcefn clone(&self) -> Dependency
fn clone(&self) -> Dependency
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more