Skip to content

use more AsRef<str>#451

Merged
NSoiffer merged 1 commit intodaisy:mainfrom
moritz-gross:use-more-AsRef
Jan 8, 2026
Merged

use more AsRef<str>#451
NSoiffer merged 1 commit intodaisy:mainfrom
moritz-gross:use-more-AsRef

Conversation

@moritz-gross
Copy link
Contributor

@moritz-gross moritz-gross commented Jan 7, 2026

except for my one comment, everything else looks very straightforward.

Copy link
Collaborator

@NSoiffer NSoiffer left a comment

Choose a reason for hiding this comment

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

Thanks. I did a little more reading about using impl AsRef<str>. The downside is that two copies of the function might get created: one for &str and one for String. So the recommendation is to tend to use impl AsRef<str> for public facing functions where convenience matters. It was also suggested that if the function is not simple, then to make the function be a wrapper around the real function so that only the short wrapper gets copied.

Of course, there is no hard and fast rule as to what is a "short" function. set_rules_dir is definitely short. I'm not sure about set_preference though. Of course, doubling up a few longer functions is not much of an issue, but we should avoid doing so for lots of functions.

@NSoiffer NSoiffer merged commit b6180ab into daisy:main Jan 8, 2026
2 of 4 checks passed
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