Skip to main content

TargetFeatures

Struct TargetFeatures 

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

A set of target features.

Implementations§

Source§

impl TargetFeatures

Source

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

Returns a suggested number of elements for a SIMD vector of type T.

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 TargetFeatures

Source

pub const fn empty() -> Self

Returns a set containing no target features.

Source

pub const fn enabled_for_target() -> Self

Returns the target features enabled at compile time.

This includes features enabled by the target specification, target CPU, and -C target-feature compiler options.

Source

pub const fn contains(self, required: Self) -> bool

Returns whether self contains every target feature in required.

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

pub const fn with(self, additional: Self) -> Self

Returns self with all target features in additional.

Trait Implementations§

Source§

impl Clone for TargetFeatures

Source§

fn clone(&self) -> TargetFeatures

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 TargetFeatures

Source§

impl Debug for TargetFeatures

Source§

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

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

impl Eq for TargetFeatures

Source§

impl Hash for TargetFeatures

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TargetFeatures

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TargetFeatures

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.