[−][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");
Implementations
impl<'a> TargetSpec<'a>
[src]
pub fn custom(target_info: &'a TargetInfo<'a>) -> Self
[src]
Creates a new exact, custom target spec to match against.
Note that this is for an exact target spec, similar to a triple specified, not an
expression like cfg(windows)
.
Custom platforms are often found in embedded and similar environments. For built-in
platforms, the FromStr
implementation is recommended instead.
pub fn eval(&self, platform: &Platform) -> Option<bool>
[src]
Evaluates this specification against the given platform.
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 features are involved).
Trait Implementations
impl<'a> Clone for TargetSpec<'a>
[src]
fn clone(&self) -> TargetSpec<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for TargetSpec<'a>
[src]
impl FromStr for TargetSpec<'static>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for TargetSpec<'a>
impl<'a> Send for TargetSpec<'a>
impl<'a> Sync for TargetSpec<'a>
impl<'a> Unpin for TargetSpec<'a>
impl<'a> UnwindSafe for TargetSpec<'a>
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,