Skip to main content

Target

Struct Target 

Source
pub struct Target { /* private fields */ }
Expand description

A target architecture with optional features.

Implementations§

Source§

impl Target

Source

pub const fn suggested_simd_width<T: SimdType>(&self) -> Option<usize>

Returns a suggested number of elements for a SIMD vector of the provided type.

The returned value is an approximation and not necessarily indicative of the optimal vector width. A few caveats:

  • Every instruction set is different, and this function doesn’t take into account any particular operations–it’s just a guess, and should be accurate at least for basic arithmetic.
  • Variable length vector instruction sets (ARM SVE and RISC-V V) only return the minimum vector length.
Source§

impl Target

Source

pub const fn new(architecture: Architecture) -> Self

Create a target with no specified features.

Source

pub const fn from_cpu( architecture: Architecture, cpu: &str, ) -> Result<Self, UnknownCpu>

Create a target based on a particular CPU.

Source

pub const fn architecture(&self) -> Architecture

Returns the target architecture.

Source

pub const fn features(&self) -> FeaturesIter

Returns an iterator over the features.

Source

pub const fn supports_feature(&self, feature: Feature) -> bool

Returns whether the target supports the specified feature.

Source

pub const fn supports_feature_str(&self, feature: &str) -> bool

Returns whether the target supports the specified feature.

§Panics

Panics if the feature doesn’t belong to the target architecture.

Examples found in repository?
examples/proof-token.rs (line 74)
65fn safe_avx_fn<P: Proof>(_: P) {
66    #[target_feature(enable = "avx")]
67    unsafe fn unsafe_avx_fn() {
68        println!("called an avx function")
69    }
70
71    // Future improvements to const generics might make it possible to assert this at compile time.
72    // Since P::TARGET is const, this assert disappears if the required features are present.
73    assert!(
74        P::TARGET.supports_feature_str("avx"),
75        "avx feature not supported"
76    );
77    unsafe { unsafe_avx_fn() }
78}
Source

pub const fn with_feature(self, feature: Feature) -> Self

Add a feature to the target.

§Panics

Panics if the feature doesn’t belong to the target architecture.

Source

pub const fn with_feature_str(self, feature: &str) -> Self

Add a feature to the target.

§Panics

Panics if the requested feature name doesn’t exist for the target architecture.

Trait Implementations§

Source§

impl Clone for Target

Source§

fn clone(&self) -> Target

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Target

Source§

impl Debug for Target

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Target

Source§

impl PartialEq for Target

Source§

fn eq(&self, other: &Target) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Target

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.