[][src]Struct guppy::Platform

pub struct Platform<'a> { /* fields omitted */ }

A platform to evaluate target specs against.

Implementations

impl<'a> Platform<'a>[src]

pub fn new(
    triple: impl AsRef<str>,
    target_features: TargetFeatures<'a>
) -> Result<Platform<'a>, Error>
[src]

Creates a new Platform from the given built-in triple and target features.

Returns None if this platform wasn't known to target-spec.

pub fn custom(
    target_info: &'a TargetInfo<'a>,
    target_features: TargetFeatures<'a>
) -> Platform<'a>
[src]

Creates a new, custom platform from a TargetInfo and target features.

Custom platforms are often found in embedded and similar environments. For built-in platforms, new is recommended instead.

pub fn add_flags(&mut self, flags: impl IntoIterator<Item = &'a str>)[src]

Adds a set of flags to accept.

A flag is a single token like the foo in cfg(not(foo)).

A default cargo build will always evaluate flags to false, but custom wrappers may cause some flags to evaluate to true. For example, as of version 0.6, cargo web build will cause cargo_web to evaluate to true.

pub fn triple(&self) -> &'a str[src]

Returns the target triple for this platform.

pub fn flags(&'b self) -> impl Iterator<Item = &'a str> + 'b[src]

Returns the set of flags enabled for this platform.

pub fn has_flag(&self, flag: impl AsRef<str>) -> bool[src]

Returns true if this flag was set with add_flags.

pub fn target_info(&self) -> &'a TargetInfo<'a>[src]

Returns the underlying TargetInfo.

pub fn target_features(&self) -> &TargetFeatures<'a>[src]

Returns the set of target features for this platform.

pub fn is_custom(&self) -> bool[src]

Returns true if this is a custom platform, created by Platform::custom.

impl Platform<'static>[src]

pub fn current() -> Option<Platform<'static>>[src]

Returns the current platform, as detected at build time.

This will return None if the current platform was unknown to this version of target-spec.

impl<'a> Platform<'a>[src]

Helpers for property testing

The methods in this section allow Platform instances to be used in property-based testing scenarios.

Currently, proptest 0.10 is supported if the proptest010 feature is enabled.

pub fn strategy(
    target_features: impl Strategy<Value = TargetFeatures<'a>> + 'a
) -> impl Strategy<Value = Platform<'a>> + 'a
[src]

Given a way to generate TargetFeatures instances, this returns a Strategy that generates a platform at random.

Requires the proptest010 feature to be enabled.

Examples

use proptest::prelude::*;
use target_spec::{Platform, TargetFeatures};

// target_features is a strategy that always produces TargetFeatures::Unknown.
let target_features = Just(TargetFeatures::Unknown);
let strategy = Platform::strategy(target_features);

pub fn filtered_strategy(
    triple_filter: impl Fn(&'static str) -> bool,
    target_features: impl Strategy<Value = TargetFeatures<'a>> + 'a
) -> impl Strategy<Value = Platform<'a>> + 'a
[src]

A version of strategy that allows target triples to be filtered.

Requires the proptest010 feature to be enabled.

Trait Implementations

impl<'a> Clone for Platform<'a>[src]

impl<'a> Debug for Platform<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Platform<'a>

impl<'a> Send for Platform<'a>

impl<'a> Sync for Platform<'a>

impl<'a> Unpin for Platform<'a>

impl<'a> UnwindSafe for Platform<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> DefaultFeatures<'a> for T where
    T: 'a + Clone + Send + Sync
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<'a, T> NonSyncFeatures<'a> for T where
    T: 'a + Clone
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> SafeBorrow<T> for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,