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
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Dependency
impl Debug for Dependency
sourceimpl<'de> Deserialize<'de> for Dependency
impl<'de> Deserialize<'de> for Dependency
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Hash for Dependency
impl Hash for Dependency
sourceimpl PartialEq<Dependency> for Dependency
impl PartialEq<Dependency> for Dependency
sourcefn eq(&self, other: &Dependency) -> bool
fn eq(&self, other: &Dependency) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Dependency) -> bool
fn ne(&self, other: &Dependency) -> bool
This method tests for !=
.
sourceimpl Serialize for Dependency
impl Serialize for Dependency
impl Eq for Dependency
impl StructuralEq for Dependency
impl StructuralPartialEq for Dependency
Auto Trait Implementations
impl RefUnwindSafe for Dependency
impl Send for Dependency
impl Sync for Dependency
impl Unpin for Dependency
impl UnwindSafe for Dependency
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more