Struct Triple
pub struct Triple { /* private fields */ }
Expand description
A single, specific target, uniquely identified by a triple.
A Triple
may be constructed through new
or the FromStr
implementation.
Every Platform
is backed by one of these.
§Standard and custom platforms
target-spec
recognizes two kinds of platforms:
-
Standard platforms: These platforms are only specified by their triple string, either directly or via a
Triple
. For example, the platformx86_64-unknown-linux-gnu
is a standard platform since it is recognized by Rust.All builtin platforms are standard platforms.
By default, if a platform isn’t builtin, target-spec attempts to heuristically determine the characteristics of the platform based on the triple string. (Use the
new_strict
constructor to disable this.) -
Custom platforms: These platforms are specified via both a triple string and a JSON file in the format defined by Rust. Custom platforms are used for targets not recognized by Rust.
§Examples
use target_spec::Triple;
// Parse a simple target.
let target = Triple::new("x86_64-unknown-linux-gnu").unwrap();
// This is not a valid triple.
let err = Triple::new("cannot-be-known").unwrap_err();
Implementations§
§impl Triple
impl Triple
pub fn new(
triple_str: impl Into<Cow<'static, str>>,
) -> Result<Triple, TripleParseError>
pub fn new( triple_str: impl Into<Cow<'static, str>>, ) -> Result<Triple, TripleParseError>
Creates a new Triple
from a triple string.
pub fn new_strict(
triple_str: impl Into<Cow<'static, str>>,
) -> Result<Triple, TripleParseError>
pub fn new_strict( triple_str: impl Into<Cow<'static, str>>, ) -> Result<Triple, TripleParseError>
Creates a new Triple
from a triple string.
This constructor only consults the builtin platform table, and does not attempt to heuristically determine the platform’s characteristics based on the triple string.
pub fn new_custom(
triple_str: impl Into<Cow<'static, str>>,
json: &str,
) -> Result<Triple, CustomTripleCreateError>
pub fn new_custom( triple_str: impl Into<Cow<'static, str>>, json: &str, ) -> Result<Triple, CustomTripleCreateError>
Creates a new custom Triple
from the given triple string and JSON specification.
pub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Returns true if this is a triple corresponding to a standard platform.
A standard platform can be either builtin, or heuristically determined.
§Examples
use target_spec::Triple;
// x86_64-unknown-linux-gnu is Linux x86_64.
let platform = Triple::new("x86_64-unknown-linux-gnu").unwrap();
assert!(platform.is_standard());
pub fn is_builtin(&self) -> bool
pub fn is_builtin(&self) -> bool
Returns true if this is a triple corresponding to a builtin platform.
§Examples
use target_spec::Triple;
// x86_64-unknown-linux-gnu is Linux x86_64, which is a Rust tier 1 platform.
let triple = Triple::new("x86_64-unknown-linux-gnu").unwrap();
assert!(triple.is_builtin());
pub fn is_heuristic(&self) -> bool
pub fn is_heuristic(&self) -> bool
Returns true if this triple was heuristically determined.
All heuristically determined platforms are standard, but most of the time, standard platforms are builtin.
§Examples
use target_spec::Triple;
// armv5te-apple-darwin is not a real platform, but target-spec can heuristically
// guess at its characteristics.
let triple = Triple::new("armv5te-apple-darwin").unwrap();
assert!(triple.is_heuristic());
Trait Implementations§
§impl Ord for Triple
impl Ord for Triple
§impl PartialOrd for Triple
impl PartialOrd for Triple
impl Eq for Triple
impl StructuralPartialEq for Triple
Auto Trait Implementations§
impl Freeze for Triple
impl RefUnwindSafe for Triple
impl Send for Triple
impl Sync for Triple
impl Unpin for Triple
impl UnwindSafe for Triple
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more