[−][src]Struct target_spec::TargetSpec
A parsed target specification or triple, as found in a Cargo.toml
file.
Use the FromStr
implementation or str::parse
to obtain an instance.
Examples
use target_spec::{Platform, TargetFeatures, TargetSpec}; let i686_windows = Platform::new("i686-pc-windows-gnu", TargetFeatures::Unknown).unwrap(); let x86_64_mac = Platform::new("x86_64-apple-darwin", TargetFeatures::none()).unwrap(); let i686_linux = Platform::new("i686-unknown-linux-gnu", TargetFeatures::features(&["sse2"])).unwrap(); let spec: TargetSpec = "cfg(any(windows, target_arch = \"x86_64\"))".parse().unwrap(); assert_eq!(spec.eval(&i686_windows), Some(true), "i686 Windows"); assert_eq!(spec.eval(&x86_64_mac), Some(true), "x86_64 MacOS"); assert_eq!(spec.eval(&i686_linux), Some(false), "i686 Linux (should not match)"); let spec: TargetSpec = "cfg(any(target_feature = \"sse2\", target_feature = \"sse\"))".parse().unwrap(); assert_eq!(spec.eval(&i686_windows), None, "i686 Windows features are unknown"); assert_eq!(spec.eval(&x86_64_mac), Some(false), "x86_64 MacOS matches no features"); assert_eq!(spec.eval(&i686_linux), Some(true), "i686 Linux matches some features");
Methods
impl TargetSpec
[src]
pub fn eval(&self, platform: &Platform) -> Option<bool>
[src]
Evaluates this specification against the given platform triple.
Returns Some(true)
if there's a match, Some(false)
if there's none, or None
if the
result of the evaluation is unknown (typically found if target families are involved).
Trait Implementations
impl Clone for TargetSpec
[src]
fn clone(&self) -> TargetSpec
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for TargetSpec
[src]
impl FromStr for TargetSpec
[src]
Auto Trait Implementations
impl RefUnwindSafe for TargetSpec
impl Send for TargetSpec
impl Sync for TargetSpec
impl Unpin for TargetSpec
impl UnwindSafe for TargetSpec
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,
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.
fn to_owned(&self) -> T
[src]
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.
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>,