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<Self, TripleParseError>
pub fn new( triple_str: impl Into<Cow<'static, str>>, ) -> Result<Self, TripleParseError>
Creates a new Triple
from a triple string.
sourcepub fn new_strict(
triple_str: impl Into<Cow<'static, str>>,
) -> Result<Self, TripleParseError>
pub fn new_strict( triple_str: impl Into<Cow<'static, str>>, ) -> Result<Self, 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 new_custom(
triple_str: impl Into<Cow<'static, str>>,
json: &str,
) -> Result<Self, CustomTripleCreateError>
Available on crate feature custom
only.
pub fn new_custom( triple_str: impl Into<Cow<'static, str>>, json: &str, ) -> Result<Self, CustomTripleCreateError>
custom
only.Creates a new custom Triple
from the given triple string and JSON specification.
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
)