Struct target_spec::Platform
source · pub struct Platform { /* private fields */ }
Expand description
A platform to evaluate target specs against.
Implementations§
source§impl Platform
impl Platform
sourcepub fn new(
triple_str: impl Into<Cow<'static, str>>,
target_features: TargetFeatures
) -> Result<Self, Error>
pub fn new( triple_str: impl Into<Cow<'static, str>>, target_features: TargetFeatures ) -> Result<Self, Error>
Creates a new Platform
from the given triple and target features.
Returns an error if this platform wasn’t known to target-spec
.
sourcepub fn current() -> Result<Self, Error>
pub fn current() -> Result<Self, Error>
Returns the current platform, as detected at build time.
This will return an error if the current platform was unknown to this version of
target-spec
.
sourcepub fn from_triple(triple: Triple, target_features: TargetFeatures) -> Self
pub fn from_triple(triple: Triple, target_features: TargetFeatures) -> Self
Creates a new platform from a Triple
and target features.
sourcepub fn add_flags(
&mut self,
flags: impl IntoIterator<Item = impl Into<Cow<'static, str>>>
)
pub fn add_flags( &mut self, flags: impl IntoIterator<Item = impl Into<Cow<'static, str>>> )
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.
sourcepub fn triple_str(&self) -> &str
pub fn triple_str(&self) -> &str
Returns the target triple string for this platform.
sourcepub fn flags(&self) -> impl Iterator<Item = &str> + ExactSizeIterator
pub fn flags(&self) -> impl Iterator<Item = &str> + ExactSizeIterator
Returns the set of flags enabled for this platform.
sourcepub fn has_flag(&self, flag: impl AsRef<str>) -> bool
pub fn has_flag(&self, flag: impl AsRef<str>) -> bool
Returns true if this flag was set with add_flags
.
sourcepub fn target_features(&self) -> &TargetFeatures
pub fn target_features(&self) -> &TargetFeatures
Returns the set of target features for this platform.
source§impl Platform
impl Platform
Helpers for property testing
The methods in this section allow Platform
instances to be used in property-based testing
scenarios.
Currently, proptest 1 is supported if the proptest1
feature is enabled.
sourcepub fn strategy(
target_features: impl Strategy<Value = TargetFeatures>
) -> impl Strategy<Value = Platform>
Available on crate feature proptest1
only.
pub fn strategy( target_features: impl Strategy<Value = TargetFeatures> ) -> impl Strategy<Value = Platform>
proptest1
only.Given a way to generate TargetFeatures
instances, this returns a Strategy
that generates
a platform at random.
Requires the proptest1
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);
sourcepub fn filtered_strategy(
triple_filter: impl Fn(&'static str) -> bool,
target_features: impl Strategy<Value = TargetFeatures>
) -> impl Strategy<Value = Platform>
Available on crate feature proptest1
only.
pub fn filtered_strategy( triple_filter: impl Fn(&'static str) -> bool, target_features: impl Strategy<Value = TargetFeatures> ) -> impl Strategy<Value = Platform>
proptest1
only.A version of strategy
that allows target triples to be filtered.
Requires the proptest1
feature to be enabled.
source§impl Platform
impl Platform
sourcepub fn to_summary(&self) -> PlatformSummary
Available on crate feature summaries
only.
pub fn to_summary(&self) -> PlatformSummary
summaries
only.Converts this Platform
to a serializable form.
Requires the summaries
feature to be enabled.
Trait Implementations§
source§impl Ord for Platform
impl Ord for Platform
source§impl PartialEq<Platform> for Platform
impl PartialEq<Platform> for Platform
source§impl PartialOrd<Platform> for Platform
impl PartialOrd<Platform> for Platform
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more