Skip to content

mcf: remove lifetime from PasswordHashRef#2116

Merged
tarcieri merged 1 commit intomasterfrom
mcf/password-hash-ref-refactor
Dec 10, 2025
Merged

mcf: remove lifetime from PasswordHashRef#2116
tarcieri merged 1 commit intomasterfrom
mcf/password-hash-ref-refactor

Conversation

@tarcieri
Copy link
Copy Markdown
Member

NOTE: breaking change

Changes the PasswordHashRef type into a repr(transparent) newtype for str, constructing it as &PasswordHashRef using an unsafe pointer cast which is only invoked after first validating it's well-formed.

This makes it possible to impl Borrow<PasswordHashRef> on PasswordHash and ToOwned on PasswordHashRef.

AsRef and Deref impls have been added to PasswordHash for obtaining a &PasswordHashRef, and the inherent methods which were duplicated on both PasswordHashRef and PasswordHash have been removed, following a similar pattern to str/String.

The PasswordHash::as_mcf_hash_ref method has been removed in favor of using any of AsRef, Borrow, or Deref to do the conversion.

NOTE: breaking change

Changes the `PasswordHashRef` type into a `repr(transparent)` newtype
for `str`, constructing it as `&PasswordHashRef` using an unsafe pointer
cast which is only invoked after first validating it's well-formed.

This makes it possible to impl `Borrow<PasswordHashRef>` on
`PasswordHash` and `ToOwned` on `PasswordHashRef`.

`AsRef` and `Deref` impls have been added to `PasswordHash` for
obtaining a `&PasswordHashRef`, and the inherent methods which were
duplicated on both `PasswordHashRef` and `PasswordHash` have been
removed, following a similar pattern to `str`/`String`.

The `PasswordHash::as_mcf_hash_ref` method has been removed in favor of
using any of `AsRef`, `Borrow`, or `Deref` to do the conversion.
@tarcieri tarcieri merged commit 8c721b5 into master Dec 10, 2025
11 checks passed
@tarcieri tarcieri deleted the mcf/password-hash-ref-refactor branch December 10, 2025 18:15
@tarcieri tarcieri mentioned this pull request Mar 8, 2026
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

Successfully merging this pull request may close these issues.

1 participant