[−][src]Struct cargo_rustc_cfg::CargoRustcPrintCfg
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]
A: IntoIterator<Item = S>,
S: AsRef<OsStr>,
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]
T: AsRef<OsStr>,
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]
A: IntoIterator<Item = S>,
S: AsRef<OsStr>,
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]
T: AsRef<OsStr>,
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]
pub fn clone(&self) -> CargoRustcPrintCfg
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CargoRustcPrintCfg
[src]
impl Default for CargoRustcPrintCfg
[src]
impl PartialEq<CargoRustcPrintCfg> for CargoRustcPrintCfg
[src]
pub fn eq(&self, other: &CargoRustcPrintCfg) -> bool
[src]
pub fn ne(&self, other: &CargoRustcPrintCfg) -> bool
[src]
impl StructuralPartialEq for CargoRustcPrintCfg
[src]
Auto Trait Implementations
impl RefUnwindSafe for CargoRustcPrintCfg
impl Send for CargoRustcPrintCfg
impl Sync for CargoRustcPrintCfg
impl Unpin for CargoRustcPrintCfg
impl UnwindSafe for CargoRustcPrintCfg
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,