Skip to main content

Dependency

Struct Dependency 

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

Represents a single dependency

Implementations§

Source§

impl Dependency

Source

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" }
Source

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"
Source

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" }
Source

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" }
Source

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" }
Source

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" }
Source

pub fn build(&self) -> Self

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

Source

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 }
Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dependency

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Dependency> for Dependency

Source§

fn from(d: &Dependency) -> Dependency

Converts to this type from the input type.
Source§

impl<'a> From<&'a Dependency> for InlineTable

Source§

fn from(dep: &'a Dependency) -> InlineTable

Converts to this type from the input type.
Source§

impl<'a> From<&'a Dependency> for Table

Source§

fn from(dep: &'a Dependency) -> Table

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut Dependency> for Dependency

Source§

fn from(d: &'a mut Dependency) -> Dependency

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for Dependency

Source§

fn from(s: &'a str) -> Dependency

Converts to this type from the input type.
Source§

impl From<Dependency> for InlineTable

Source§

fn from(d: Dependency) -> InlineTable

Converts to this type from the input type.
Source§

impl From<String> for Dependency

Source§

fn from(s: String) -> Dependency

Converts to this type from the input type.
Source§

impl PartialEq for Dependency

Source§

fn eq(&self, other: &Dependency) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Dependency

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.