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

Represents a single dependency

Implementations

Constructs a Depedency that points to a git repo

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::repo("foo", "https://github.com/foo/bar");
// translates to:
// [dependencies]
// foo = { git = "https://github.com/foo/bar" }

Constructs a Depedency that specifies a semver version

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::version("foo", "0.1.0");
// translates to:
// [dependencies]
// foo = "0.1.0"

Constructs a Depedency that points to a path

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::path("foo", "/path/to/foo");
// translates to:
// [dependencies]
// foo = { path = "/path/to/foo" }

Constructs a Depedency that points to a specific revision of a repository

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::rev("foo", "https://github.com/foo/bar", "0a14cbe3928");
// translates to:
// [dependencies]
// foo = { git = "https://github.com/foo/bar", rev = "0a14cbe3928" }

Constructs a Depedency that points to a specific tag of a repository

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::tag("foo", "https://github.com/foo/bar", "v1.0.0");
// translates to:
// [dependencies]
// foo = { git = "https://github.com/foo/bar", tag = "v1.0.0" }

Constructs a Depedency that points to a specific branch of a repository

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::branch("foo", "https://github.com/foo/bar", "some-branch");
// translates to:
// [dependencies]
// foo = { git = "https://github.com/foo/bar", branch = "some-branch" }

If the builder pattern has been used to construct this Dependency, this takes ownership

Mark this dependency as “optional = true”

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::version("foo", "0.1.0")
                     .optional(true)
                     .build();
// translates to:
// [dependencies]
// foo = { version = "0.1.0", optional = true }

Specify whether this dependency is using the default features or not

Example
extern crate cargo_toml_builder;
use cargo_toml_builder::prelude::*;
let dep = Dependency::version("foo", "0.1.0")
                     .default_features(false)
                     .build();
// translates to:
// [dependencies]
// foo = { version = "0.1.0", default-features = false }

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
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.