Struct cargo_toml_builder::types::Dependency
source · pub struct Dependency { /* private fields */ }
Expand description
Represents a single dependency
Implementations
sourceimpl 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
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 moresourceimpl Debug for Dependency
impl Debug for Dependency
sourceimpl<'a> From<&'a Dependency> for Dependency
impl<'a> From<&'a Dependency> for Dependency
sourcefn from(d: &Dependency) -> Dependency
fn from(d: &Dependency) -> Dependency
Converts to this type from the input type.
sourceimpl<'a> From<&'a Dependency> for InlineTable
impl<'a> From<&'a Dependency> for InlineTable
sourcefn from(dep: &'a Dependency) -> InlineTable
fn from(dep: &'a Dependency) -> InlineTable
Converts to this type from the input type.
sourceimpl<'a> From<&'a Dependency> for Table
impl<'a> From<&'a Dependency> for Table
sourcefn from(dep: &'a Dependency) -> Table
fn from(dep: &'a Dependency) -> Table
Converts to this type from the input type.
sourceimpl<'a> From<&'a mut Dependency> for Dependency
impl<'a> From<&'a mut Dependency> for Dependency
sourcefn from(d: &'a mut Dependency) -> Dependency
fn from(d: &'a mut Dependency) -> Dependency
Converts to this type from the input type.
sourceimpl<'a> From<&'a str> for Dependency
impl<'a> From<&'a str> for Dependency
sourcefn from(s: &'a str) -> Dependency
fn from(s: &'a str) -> Dependency
Converts to this type from the input type.
sourceimpl From<Dependency> for InlineTable
impl From<Dependency> for InlineTable
sourcefn from(d: Dependency) -> InlineTable
fn from(d: Dependency) -> InlineTable
Converts to this type from the input type.
sourceimpl From<String> for Dependency
impl From<String> for Dependency
sourcefn from(s: String) -> Dependency
fn from(s: String) -> Dependency
Converts to this type from the input type.
sourceimpl PartialEq<Dependency> for Dependency
impl PartialEq<Dependency> for Dependency
sourcefn eq(&self, other: &Dependency) -> bool
fn eq(&self, other: &Dependency) -> bool
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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