Skip to content

boolean vector constructors cannot be const yet #336

Description

@gnzlbg

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions