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§
Source§impl Triple
impl Triple
Sourcepub 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.
Sourcepub 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.
Sourcepub 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());
Sourcepub 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());
Sourcepub 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§
Source§impl Ord for Triple
impl Ord for Triple
Source§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
)Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.