pub struct AutoCfg { /* private fields */ }
Expand description
Helper to detect compiler features for cfg
output in build scripts.
Implementations
sourceimpl AutoCfg
impl AutoCfg
sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Create a new AutoCfg
instance.
Common errors
rustc
can’t be executed, fromRUSTC
or in thePATH
.- The version output from
rustc
can’t be parsed. OUT_DIR
is not set in the environment, or is not a writable directory.
sourcepub fn with_dir<T: Into<PathBuf>>(dir: T) -> Result<Self, Error>
pub fn with_dir<T: Into<PathBuf>>(dir: T) -> Result<Self, Error>
Create a new AutoCfg
instance with the specified output directory.
Common errors
rustc
can’t be executed, fromRUSTC
or in thePATH
.- The version output from
rustc
can’t be parsed. dir
is not a writable directory.
sourcepub fn probe_rustc_version(&self, major: usize, minor: usize) -> bool
pub fn probe_rustc_version(&self, major: usize, minor: usize) -> bool
Test whether the current rustc
reports a version greater than
or equal to “major
.minor
”.
sourcepub fn emit_rustc_version(&self, major: usize, minor: usize)
pub fn emit_rustc_version(&self, major: usize, minor: usize)
Sets a cfg
value of the form rustc_major_minor
, like rustc_1_29
,
if the current rustc
is at least that version.
sourcepub fn probe_sysroot_crate(&self, name: &str) -> bool
pub fn probe_sysroot_crate(&self, name: &str) -> bool
Tests whether the given sysroot crate can be used.
The test code is subject to change, but currently looks like:
extern crate CRATE as probe;
sourcepub fn emit_sysroot_crate(&self, name: &str)
pub fn emit_sysroot_crate(&self, name: &str)
Emits a config value has_CRATE
if probe_sysroot_crate
returns true.
sourcepub fn probe_path(&self, path: &str) -> bool
pub fn probe_path(&self, path: &str) -> bool
Tests whether the given path can be used.
The test code is subject to change, but currently looks like:
pub use PATH;
sourcepub fn emit_has_path(&self, path: &str)
pub fn emit_has_path(&self, path: &str)
Emits a config value has_PATH
if probe_path
returns true.
Any non-identifier characters in the path
will be replaced with
_
in the generated config value.
sourcepub fn emit_path_cfg(&self, path: &str, cfg: &str)
pub fn emit_path_cfg(&self, path: &str, cfg: &str)
Emits the given cfg
value if probe_path
returns true.
sourcepub fn probe_trait(&self, name: &str) -> bool
pub fn probe_trait(&self, name: &str) -> bool
Tests whether the given trait can be used.
The test code is subject to change, but currently looks like:
pub trait Probe: TRAIT + Sized {}
sourcepub fn emit_has_trait(&self, name: &str)
pub fn emit_has_trait(&self, name: &str)
Emits a config value has_TRAIT
if probe_trait
returns true.
Any non-identifier characters in the trait name
will be replaced with
_
in the generated config value.
sourcepub fn emit_trait_cfg(&self, name: &str, cfg: &str)
pub fn emit_trait_cfg(&self, name: &str, cfg: &str)
Emits the given cfg
value if probe_trait
returns true.
sourcepub fn probe_type(&self, name: &str) -> bool
pub fn probe_type(&self, name: &str) -> bool
Tests whether the given type can be used.
The test code is subject to change, but currently looks like:
pub type Probe = TYPE;
sourcepub fn emit_has_type(&self, name: &str)
pub fn emit_has_type(&self, name: &str)
Emits a config value has_TYPE
if probe_type
returns true.
Any non-identifier characters in the type name
will be replaced with
_
in the generated config value.
sourcepub fn emit_type_cfg(&self, name: &str, cfg: &str)
pub fn emit_type_cfg(&self, name: &str, cfg: &str)
Emits the given cfg
value if probe_type
returns true.
sourcepub fn probe_expression(&self, expr: &str) -> bool
pub fn probe_expression(&self, expr: &str) -> bool
Tests whether the given expression can be used.
The test code is subject to change, but currently looks like:
pub fn probe() { let _ = EXPR; }
sourcepub fn emit_expression_cfg(&self, expr: &str, cfg: &str)
pub fn emit_expression_cfg(&self, expr: &str, cfg: &str)
Emits the given cfg
value if probe_expression
returns true.
sourcepub fn probe_constant(&self, expr: &str) -> bool
pub fn probe_constant(&self, expr: &str) -> bool
Tests whether the given constant expression can be used.
The test code is subject to change, but currently looks like:
pub const PROBE: () = ((), EXPR).0;
sourcepub fn emit_constant_cfg(&self, expr: &str, cfg: &str)
pub fn emit_constant_cfg(&self, expr: &str, cfg: &str)
Emits the given cfg
value if probe_constant
returns true.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for AutoCfg
impl Send for AutoCfg
impl Sync for AutoCfg
impl Unpin for AutoCfg
impl UnwindSafe for AutoCfg
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more