Skip to content

Commit 4e06b95

Browse files
authored
cpufeatures: add InitToken::{init, init_get} (#1435)
Makes these methods callable as constructor methods for `InitToken`. This makes for only one thing you have to re-export if you want to provide `InitToken` to other modules within a crate, or potentially as a `pub` re-export as e.g. part of a `hazmat` API.
1 parent 7eb6406 commit 4e06b95

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cpufeatures/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@ macro_rules! new {
4545
pub struct InitToken(());
4646

4747
impl InitToken {
48-
/// Get initialized value
48+
/// Initialize token, performing CPU feature detection.
49+
pub fn init() -> Self {
50+
init()
51+
}
52+
53+
/// Initialize token and return a `bool` indicating if the feature is supported.
54+
pub fn init_get() -> (Self, bool) {
55+
init_get()
56+
}
57+
58+
/// Get initialized value.
4959
#[inline(always)]
5060
pub fn get(&self) -> bool {
5161
$crate::__unless_target_features! {

0 commit comments

Comments
 (0)