{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreicnt7fwmcadktpsivevjy6zx2i72zr5ese4nv457u2l655xe6yqci",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mmpeuyk5q6j2"
},
"path": "/t/pre-rfc-make-some-feature-detected-function-to-fn-pointer-casts-safe-through-zst-token-types/24353#post_6",
"publishedAt": "2026-05-25T19:36:40.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "Doing a function pointer cast seems to me like a very direct way to do multi-version dispatch.\n\nWould it be any easier to implement if the cast didn't use ZST's but was just a macro? There's already `is_x86_feature_detected` so the main thing would be checking the target_feature on the passed method (which I suppose probably isn't known until after macro expansion but may that's solvable?)\n\n\n #[target_feature(enable = \"sse4.1\")]\n fn crazy() {\n …\n }\n\n fn boring_scalar_implementation() {\n …\n }\n\n fn choose_implementation() -> ... {\n let sse_impl: Option<_> = try_target_feature_cast!(\"sse4.1\", crazy);\n\n see_impl.unwrap_or(boring_scalar_implementation)\n }\n\n",
"title": "[Pre-RFC] Make some feature-detected function-to-fn-pointer casts safe through ZST token types"
}