Skip to content

Conversation

@H2CO3
Copy link
Contributor

@H2CO3 H2CO3 commented Jun 13, 2025

What does this PR do?

Some public functions had &Option<T> as one of their arguments. This is undesirable, because it forces the caller to have a literal Option<T> to which a reference is then taken.

If the caller only has a T that it does not wish to consume, this forces a clone. Taking an Option<&T> is more flexible, as &Option<T> can be converted to Option<&T> using the Option::as_ref() inherent method, and if one already has a bare T, then it's easy to create an Option<&T> by taking its address and wrapping it into Some.

The call site is also slightly simplified, as one no longer needs to write &None.

Copy link
Contributor

@Narsil Narsil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for splitting this.

@Narsil Narsil merged commit 573305d into huggingface:main Jun 15, 2025
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.

2 participants