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

[stdlib] Introduce Hasher type with all necessary changes #2619

Draft
wants to merge 1 commit into
base: nightly
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions stdlib/src/builtin/dtype.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ struct DType(Stringable, Representable, KeyElement):
self._as_i8(), rhs._as_i8()
)

fn __hash__(self) -> Int:
return hash(UInt8(self._as_i8()))
@always_inline
fn __hash__[H: Hasher](self, inout hasher: H):
hasher._update_with_simd(UInt8(self._as_i8()))

@always_inline("nodebug")
fn isa[other: DType](self) -> Bool:
Expand Down