feature_probe

Struct Probe

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

A probe object, which is used for probing for features.

Create this with ProbeProbeo::new, and then probe with one of the probing methods.

Implementations§

Source§

impl Probe

Source

pub fn new() -> Self

Creates a new Probe object with a default configuration.

In particular, it consults the environment variable "RUSTC" to determine what Rust compiler to use, and the environment variable "OUT_DIR" to determine where to put object files. If these are not set, they default to the values "rustc" and "target", respectively.

§Panics

If the child rustc cannot be started or communicated with.

§Examples
use feature_probe::Probe;

let probe = Probe::new();
assert!( probe.probe_type("u32") );
Source

pub fn probe_type(&self, type_name: &str) -> bool

Probes for the existence of the given type by name.

§Panics

If the child rustc cannot be started or communicated with.

§Examples
use feature_probe::Probe;

let probe = Probe::new();
assert!(   probe.probe_type("u32") );
assert!( ! probe.probe_type("u512") );
Source

pub fn probe_expression(&self, expression: &str) -> bool

Probes whether the given expression can be compiled.

§Examples
use feature_probe::Probe;

let probe = Probe::new();
assert!(   probe.probe_expression("3 + 4") );
assert!( ! probe.probe_expression("3 + true") );
Source

pub fn probe(&self, code: &str) -> bool

Probes for whether a whole program can be compiled.

§Panics

If the child rustc cannot be started or communicated with.

§Examples
use feature_probe::Probe;

let probe = Probe::new();
assert!(   probe.probe("fn main() { }") );
assert!( ! probe.probe("fn main(args: Vec<String>) { }") );
Source

pub fn probe_result(&self, code: &str) -> Result<bool>

Probes for whether a whole program can be compiled.

§Examples
use feature_probe::Probe;

let probe = Probe::new();
assert_eq!( probe.probe_result("fn main() { }").unwrap(),                  true );
assert_eq!( probe.probe_result("fn main(args: Vec<String>) { }").unwrap(), false );

Trait Implementations§

Source§

impl Debug for Probe

Source§

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

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

impl Default for Probe

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Probe

§

impl RefUnwindSafe for Probe

§

impl Send for Probe

§

impl Sync for Probe

§

impl Unpin for Probe

§

impl UnwindSafe for Probe

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> 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, 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.