[][src]Struct cargo_rustc_cfg::CargoRustcPrintCfg

pub struct CargoRustcPrintCfg { /* fields omitted */ }

A builder type for the cargo rustc --lib -- --print cfg command.

For reference, the default command signature is:

cargo rustc --lib -- --print cfg

and the more generic command signature represented by this type is:

cargo <TOOLCHAIN> rustc <CARGO_ARGS> <CARGO_TARGET> <RUSTC_TARGET> -- <RUSTC_ARGS> --print cfg

where <TOOLCHAIN> is replaced with the cargo_toolchain value, the <CARGO_ARGS> is replaced with the cargo_args value, the <CARGO_TARGET> is replaced with the cargo_target value, the <RUSTC_TARGET> is replaced with the rustc_target value, and the <RUSTC_ARGS> is replaced with the rustc_args value.

Implementations

impl CargoRustcPrintCfg[src]

pub fn cargo_args<A, S>(&mut self, a: A) -> &mut Self where
    A: IntoIterator<Item = S>,
    S: AsRef<OsStr>, 
[src]

Adds arguments to the Cargo command after the rustc subcommand but before the <CARGO_TARGET> and <RUSTC_TARGET> arguments.

For reference, the default command is:

cargo rustc --lib -- --print cfg

and this method adds arguments between rustc and --lib to yield:

cargo rustc <CARGO_ARGS> --lib -- --print cfg

pub fn cargo_target(&mut self, t: CargoTarget) -> &mut Self[src]

Specifies a single Cargo target.

When passing arguments to the Rust compiler (rustc) using the -- flag, only one Cargo target can be used. By default, the library target will be used. Use this method to specify a specific Cargo target other than the library target.

For reference, the default command is:

cargo rustc --lib -- --print cfg

and this method replaces the --lib with --bin <NAME>, --bench <NAME>, --example <NAME>, or --test <NAME>, respectively.

pub fn cargo_toolchain<T>(&mut self, t: T) -> &mut Self where
    T: AsRef<OsStr>, 
[src]

Specify a toolchain to use.

The toolchain must be installed on the host system before specifying it with this method. It is recommended to install and manage various toolchains using the rustup application.

The plus sign, +, is prepended automatically. Please do not include it as part of the toolchain value.

For reference, the default command is:

cargo rustc --lib -- --print cfg

and this method would add +<TOOLCHAIN> between cargo and rustc to yield:

cargo +<TOOLCHAIN> rustc --lib -- --print cfg

pub fn rustc_args<A, S>(&mut self, a: A) -> &mut Self where
    A: IntoIterator<Item = S>,
    S: AsRef<OsStr>, 
[src]

Adds arguments to the Cargo command after the -- flag but before the --print cfg arguments.

For reference, the default command is:

cargo rustc --lib -- --print cfg

and this method adds arguments between -- and --print cfg to yield:

cargo rustc --lib -- <RUSTC_ARGS> --print cfg

pub fn rustc_target<T>(&mut self, t: T) -> &mut Self where
    T: AsRef<OsStr>, 
[src]

Specify a Rust compiler (rustc) target via a target triple.

The rustc target must be installed on the host system before specifying it with this method. It is recommended to install and manage targets for various toolchains using the rustup application.

The --target argument is prepended automatically. Please do not include it as part of the target triple value.

For reference, the default command is:

cargo rustc --lib -- --print cfg

and this method would add --target <RUSTC_TARGET> between --lib and -- to yield:

cargo rustc --lib --target <RUSTC_TARGET> -- --print cfg

where <RUSTC_TARGET> is a target triple from the rustc --print target-list output..

pub fn execute(&self) -> Result<Cfg, Error>[src]

This executes the cargo rustc subcommand with the appropriate options.

For reference, the generic command signature:

`cargo <TOOLCHAIN> rustc <CARGO_ARGS> <CARGO_TARGET> <RUSTC_TARGET> -- <RUSTC_ARGS> --print cfg`

where <TOOLCHAIN> is replaced with the cargo_toolchain value, the <CARGO_ARGS> is replaced with the cargo_args value, the <CARGO_TARGET> is replaced with the cargo_target value, the <RUSTC_TARGET> is appropriately replaced with --target <RUSTC_TARGET> from the rustc_target value, and the <RUSTC_ARGS> is replaced with the rustc_args value.

Examples

If the host is a Windows target:

let cfg = CargoRustcPrintCfg::default().execute()?;
assert_eq!(cfg.target().arch(), "x86_64");
assert_eq!(cfg.target().endian(), "little");
assert_eq!(cfg.target().env(), Some("msvc"));
assert_eq!(cfg.target().family(), Some("windows"));
assert_eq!(cfg.target().os(), "windows");
assert_eq!(cfg.target().pointer_width(), "64");
assert_eq!(cfg.target().vendor(), Some("pc"));

If the host is a Linux target:

let cfg = CargoRustcPrintCfg::default().execute()?;
assert_eq!(cfg.target().arch(), "x86_64");
assert_eq!(cfg.target().endian(), "little");
assert_eq!(cfg.target().env(), None);
assert_eq!(cfg.target().family(), Some("unix"));
assert_eq!(cfg.target().os(), "os");
assert_eq!(cfg.target().pointer_width(), "64");
assert_eq!(cfg.target().vendor(), Some("unknown"));

If the host is an Apple target:

let cfg = CargoRustcPrintCfg::default().execute()?;
assert_eq!(cfg.target().arch(), "x86_64");
assert_eq!(cfg.target().endian(), "little");
assert_eq!(cfg.target().env(), None);
assert_eq!(cfg.target().family(), Some("unix"));
assert_eq!(cfg.target().os(), "os");
assert_eq!(cfg.target().pointer_width(), "64");
assert_eq!(cfg.target().vendor(), Some("apple"));

Trait Implementations

impl Clone for CargoRustcPrintCfg[src]

impl Debug for CargoRustcPrintCfg[src]

impl Default for CargoRustcPrintCfg[src]

impl PartialEq<CargoRustcPrintCfg> for CargoRustcPrintCfg[src]

impl StructuralPartialEq for CargoRustcPrintCfg[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.