pub struct Dependency { /* private fields */ }Expand description
Represents a single dependency
Implementations§
Source§impl Dependency
impl Dependency
Sourcepub fn repo(label: &str, repo: &str) -> Dependency
pub fn repo(label: &str, repo: &str) -> Dependency
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" }Sourcepub fn version(label: &str, version: &str) -> Dependency
pub fn version(label: &str, version: &str) -> Dependency
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"Sourcepub fn path(label: &str, path: &str) -> Dependency
pub fn path(label: &str, path: &str) -> Dependency
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" }Sourcepub fn rev(label: &str, repo: &str, rev: &str) -> Dependency
pub fn rev(label: &str, repo: &str, rev: &str) -> Dependency
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" }Sourcepub fn tag(label: &str, repo: &str, tag: &str) -> Dependency
pub fn tag(label: &str, repo: &str, tag: &str) -> Dependency
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" }Sourcepub fn branch(label: &str, repo: &str, branch: &str) -> Dependency
pub fn branch(label: &str, repo: &str, branch: &str) -> Dependency
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" }Sourcepub fn build(&self) -> Self
pub fn build(&self) -> Self
If the builder pattern has been used to construct this Dependency, this takes ownership
Sourcepub fn optional(&mut self, optional: bool) -> &mut Self
pub fn optional(&mut self, optional: bool) -> &mut Self
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 }Sourcepub fn default_features(&mut self, default_features: bool) -> &mut Self
pub fn default_features(&mut self, default_features: bool) -> &mut Self
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§
Source§impl Clone for Dependency
impl Clone for Dependency
Source§fn clone(&self) -> Dependency
fn clone(&self) -> Dependency
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Dependency
impl Debug for Dependency
Source§impl<'a> From<&'a Dependency> for Dependency
impl<'a> From<&'a Dependency> for Dependency
Source§fn from(d: &Dependency) -> Dependency
fn from(d: &Dependency) -> Dependency
Converts to this type from the input type.
Source§impl<'a> From<&'a Dependency> for InlineTable
impl<'a> From<&'a Dependency> for InlineTable
Source§fn from(dep: &'a Dependency) -> InlineTable
fn from(dep: &'a Dependency) -> InlineTable
Converts to this type from the input type.
Source§impl<'a> From<&'a Dependency> for Table
impl<'a> From<&'a Dependency> for Table
Source§fn from(dep: &'a Dependency) -> Table
fn from(dep: &'a Dependency) -> Table
Converts to this type from the input type.
Source§impl<'a> From<&'a mut Dependency> for Dependency
impl<'a> From<&'a mut Dependency> for Dependency
Source§fn from(d: &'a mut Dependency) -> Dependency
fn from(d: &'a mut Dependency) -> Dependency
Converts to this type from the input type.
Source§impl<'a> From<&'a str> for Dependency
impl<'a> From<&'a str> for Dependency
Source§fn from(s: &'a str) -> Dependency
fn from(s: &'a str) -> Dependency
Converts to this type from the input type.
Source§impl From<Dependency> for InlineTable
impl From<Dependency> for InlineTable
Source§fn from(d: Dependency) -> InlineTable
fn from(d: Dependency) -> InlineTable
Converts to this type from the input type.
Source§impl From<String> for Dependency
impl From<String> for Dependency
Source§fn from(s: String) -> Dependency
fn from(s: String) -> Dependency
Converts to this type from the input type.
Source§impl PartialEq for Dependency
impl PartialEq for Dependency
Source§fn eq(&self, other: &Dependency) -> bool
fn eq(&self, other: &Dependency) -> bool
Tests for
self and other values to be equal, and is used by ==.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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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