8000 fix: Take Into<Cow> instead of &str by Muscraft · Pull Request #232 · rust-lang/annotate-snippets-rs · GitHub
[go: up one dir, main page]

Skip to content

fix: Take Into<Cow> instead of &str #232

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Muscraft
Copy link
Member
@Muscraft Muscraft commented Jun 27, 2025

Fixes #200

@Muscraft Muscraft changed the title fix: Take Cow instead of &str fix: Take Into<Cow> instead of &str Jun 27, 2025
@@ -2448,7 +2448,7 @@ fn secondary_title_no_level_text() {
)
.element(
Level::NOTE
.text(None)
.text(None::<&str>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

sadly yes

Copy link
Contributor

Choose a reason for hiding this comment

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

How come and then why does OptionCow exist? I thought it was to bypass this problem

Copy link
Member Author

Choose a reason for hiding this comment

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

::<&str> is needed because the type of None can't be inferred, as the From impl for Option is generic over T: Into<Cow<'a, str>>. This problem would still exist if we were to write out the different From.

OptionCow exists to solve the more common case of passing in a literal without also needing to write Some().

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.

Owned variants of APIs where &str is used
2 participants
0