Skip to content

Conversation

@emamoah
Copy link

@emamoah emamoah commented Dec 30, 2025

Although this is unambiguous after understanding it, I feel it could use a bit more clarity. The first time I read this, I was mostly confused. Many times, without even knowing. Since there was an assignment going on (*input = val;), I thought the compatibility was referring to that assignment. This proposal makes it clear, especially to new readers, where exactly this compatibility lies.

Although this is unambiguous after understanding it, I feel it could use a bit more clarity. The first time I read this, I was mostly confused. Many times, without even knowing. Since there was an assignment going on (`*input = val;`), I thought the compatibility was referring to THAT assignment. This proposal makes it clear, especially to new readers, where exactly this compatibility lies.
@emamoah
Copy link
Author

emamoah commented Dec 30, 2025

On second thought, this might not be the best clarification, considering that there's no explicit indication of 'b in the code. It's "inside" the T. But then again, T gets substituted with 'static, as we see later on. Perhaps, a re-wording of the paragraph might help, but I'm not sure what that might be. Perhaps no clarification is needed at all.

@emamoah
Copy link
Author

emamoah commented Dec 30, 2025

On third thought (and this demonstrates the subtlety), I do understand that in the assignment, the first T (&'static str) is being replaced with the second T (&'b str), and so it does make some sense that the compatibility refers to the assignment. Maybe the only issue here is the invisibility of 'b in the snippet. It might after all not be a problem.

@emamoah
Copy link
Author

emamoah commented Dec 31, 2025

I think I've got a clearer and more accurate suggestion:

The problem is that we cannot assume &'static str can still be downgraded into &'world str to satisfy T, once it's behind a &mut reference. This means that &mut &'static str cannot be a subtype of &mut &'world str, even if 'static is a subtype of 'world.

It also now uses 'world as in the previous snippets to stay consistent.

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