Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boolean vector constructors cannot be const yet #336

Closed
gnzlbg opened this issue Mar 1, 2018 · 1 comment
Closed

boolean vector constructors cannot be const yet #336

gnzlbg opened this issue Mar 1, 2018 · 1 comment

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 1, 2018

Because const fn does not support if-else branches:

#[inline]
pub /*const*/ fn new($($elem_name: bool),*) -> Self {
    $id($(Self::bool_to_internal($elem_name)),*)
}

#[inline]
/* const */ fn bool_to_internal(x: bool) -> $elem_ty {
    if x  {
        !(0 as $elem_ty)
    } else {
        0 as $elem_ty
    }
}

#[inline]
pub /*const*/ fn splat(value: bool) -> Self {
    let value = Self::bool_to_internal(value);
    $id($({
        #[allow(non_camel_case_types, dead_code)]
        struct $elem_name;
        value
    }),*)
}

EDIT: this issue will make sense as soon as I send the boolean vector PR.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Mar 5, 2018

Thanks to @rkruppe's suggestion boolean vectors now have const constructors in #338 .

@gnzlbg gnzlbg closed this as completed Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant