Skip to content

boolean vector constructors cannot be const yet #336

Closed
@gnzlbg

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.

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