-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Trying to improve the documentation for App::data() #1736
Conversation
Oh, nightly encounters an ICE, I believe that's rust-lang/rust#77993. |
extract |
Thank you @fakeshadow, that is very helpful. I never looked at it that way. I'll try to adjust the docs. Also thanks @JohnTitor I was a bit surprised that my docs-only change causes a failure. |
/// This means that only the first invocation of this function per type will have an effect, | ||
/// all later ones will be ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true, or is it the last invocation is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did look at the code back then and I thought this is what it does but I can take another look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to be honest: I don't understand (anymore) how this is used. If one of you has any insights I'll happily add it otherwise I'd just remove that sentence.
It would be good to document the behavior though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know what you're right, and that's surprising behavior actually because .app_data works differently; a bug, even.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity (because I couldn't trace it anymore but I know I did in the past): Can you point me at the location where this happens?
PR Type
Other (Documentation only)
PR Checklist
Check your PR fulfills the following:
Overview
This is related to the discussion in #1454 which aims to eventually change the semantics of
data
and/orapp_data
. In the meantime I found the documentation very confusing and in this PR I'm trying to clarify what's going on.That said: I still don't fully understand it so I set it as a draft PR and am looking for feedback on what might be changed.
My main open question is why
data
wraps in an Arc at all.I'm new to Rust so I might be missing very obvious things but by my understanding Actix runs the application factory closure once per thread it instantiates so the data does not need to be Send because it's instantiated in the target thread and it doesn't need to be Sync (by default) either, no?
If anyone could help clarify I'd try to adopt the documentation.