Module detect

Source
๐Ÿ”ฌThis is a nightly-only experimental API. (stdarch_internal)
Expand description

This module implements run-time feature detection.

The is_{arch}_feature_detected!("feature-name") macros take the name of a feature as a string-literal, and return a boolean indicating whether the feature is enabled at run-time or not.

These macros do two things:

  • map the string-literal into an integer stored as a Feature enum,
  • call a os::check_for(x: Feature) function that returns true if the feature is enabled.

The Feature enums are also implemented in the arch/{target_arch}.rs modules.

The check_for functions are, in general, Operating System dependent. Most architectures do not allow user-space programs to query the feature bits due to security concerns (x86 is the big exception). These functions are implemented in the os/{target_os}.rs modules.

Re-exportsยง

#[doc(hidden)] pub use self::arch::__is_feature_detected;Experimental

Modulesยง

arch ๐Ÿ”’ Experimental
bit ๐Ÿ”’ Experimental
Bit manipulation utilities.
cache ๐Ÿ”’ Experimental
Caches run-time feature detection so that it only needs to be computed once.
macros ๐Ÿ”’ Experimental
os ๐Ÿ”’ Experimental
x86 run-time feature detection is OS independent.

Functionsยง

check_for ๐Ÿ”’ Experimental
Performs run-time feature detection.
featuresExperimental
Returns an Iterator<Item=(&'static str, bool)> where Item.0 is the feature name, and Item.1 is a bool which is true if the feature is supported by the host and false otherwise.