Misc 1 @WaffleLapkin @BoxyUwU
Warning: this quiz is still "work-in-progress", some questions might not have good explanations (or any at all), formatting/structure/titles/etc are not final, and so on. You might want to return here on a later date.
pub unsafe const fn my_zeroed<T>() -> T {
assert!(std::mem::size_of::<T>() <= 256);
std::mem::transmute_copy(&[0u8; 256])
}
fn main() {
unsafe {
my_zeroed::<[*mut u32; 64]>();
}
}
Solution
error: expected one of `extern` or `fn`, found keyword `const`
--> examples/misc_1.rs:1:12
|
1 | pub unsafe const fn my_zeroed<T>() -> T {
| -------^^^^^
| | |
| | expected one of `extern` or `fn`
| help: `const` must come before `unsafe`: `const unsafe`
|
= note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
error: could not compile `code` (example "misc_1") due to 1 previous error
As the error says, there is a given order function qualifiers must go in.