pub struct Dependency { /* private fields */ }
Expand description

Information about a dependency requested by a Cargo manifest. Cheap to copy.

Implementations

Attempt to create a Dependency from an entry in the manifest.

This is the name of this Dependency as listed in Cargo.toml.

Or in other words, this is what shows up in the [dependencies] section on the left hand side. This is not the name of the package that’s being depended on as the dependency can be renamed. For that use package_name below.

Both of the dependencies below return foo for name_in_toml:

[dependencies]
foo = "0.1"

and …

[dependencies]
foo = { version = "0.1", package = 'bar' }

The name of the package that this Dependency depends on.

Usually this is what’s written on the left hand side of a dependencies section, but it can also be renamed via the package key.

Both of the dependencies below return foo for package_name:

[dependencies]
foo = "0.1"

and …

[dependencies]
bar = { version = "0.1", package = 'foo' }

Sets whether the dependency is public.

If none, this dependencies must be built for all platforms. If some, it must only be built for the specified platform.

The renamed name of this dependency, if any.

If the package key is used in Cargo.toml then this returns the same value as name_in_toml.

Sets the list of features requested for the package.

Sets whether the dependency requests default features of the package.

Sets whether the dependency is optional.

Sets the source ID for this dependency.

Sets the version requirement for this dependency.

Locks this dependency to depending on the specified package ID.

Locks this dependency to a specified version.

Mainly used in dependency patching like [patch] or [replace], which doesn’t need to lock the entire dependency to a specific PackageId.

Returns true if this is a “locked” dependency. Basically a locked dependency has an exact version req, but not vice versa.

Returns false if the dependency is only used to build the local package.

Returns true if the default features of the dependency are requested.

Returns the list of features that are requested by the dependency.

Returns true if the package (sum) can fulfill this dependency request.

Returns true if the package (id) can fulfill this dependency request.

Returns true if the package (id) can fulfill this dependency request.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.