Skip to content

Relationship between From/Into and FromBits traits? #413

@hdevalence

Description

@hdevalence

This change is mentioned in #338 , but I didn't see discussion of it there, so sorry if I'm missing something.

What's the intended relationship between the FromBits trait and the From/Into traits? I guess that FromBits is a more specialized trait to indicate that it's a lossless bitcast, but I am curious if there is a reason why that's better than allowing the use of From and Into.

Previously, the platform-specific intrinsics took portable vector types (e.g., u32x8) as arguments; these vector types implemented From/Into, so for the "overtyped" intrinsics it was possible to use .into() in appropriate places to do bitcasts. Now, all of the intrinsics have been changed to use bag-of-bits types, like __m256i, but there's no implementation of From/Into between the bag-of-bits types and the typed vectors of the same widths.

While there is the FromBits trait, because it's different from From, it's no longer possible to use .into() on the results of a platform intrinsic. Is there a strong reason to have FromBits distinct from From?

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