pub struct Dependency { /* private fields */ }
Expand description
A single dependency of a specific crate version
Implementations§
Source§impl 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 registry(&self) -> Option<&str>
pub fn registry(&self) -> Option<&str>
The registry URL, if available.
Example: https://github.com/rust-lang/crates.io-index.git
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§
Source§impl Clone for Dependency
impl Clone for Dependency
Source§fn clone(&self) -> Dependency
fn clone(&self) -> Dependency
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Dependency
impl Debug for Dependency
Source§impl<'de> Deserialize<'de> for Dependency
impl<'de> Deserialize<'de> for Dependency
Source§fn 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>,
Source§impl Hash for Dependency
impl Hash for Dependency
Source§impl PartialEq for Dependency
impl PartialEq for Dependency
Source§impl Serialize for Dependency
impl Serialize for Dependency
impl Eq for Dependency
impl StructuralPartialEq for Dependency
Auto Trait Implementations§
impl Freeze for Dependency
impl RefUnwindSafe for Dependency
impl Send for Dependency
impl Sync for Dependency
impl Unpin for Dependency
impl UnwindSafe for Dependency
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
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)
clone_to_uninit
)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
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more