-
-
Notifications
You must be signed in to change notification settings - Fork 321
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
Deprecate ResourceExt::name in favour of safe name_* alternatives #945
Conversation
Also add name_or_generatename returning an optional. Long term want to remove name and maybe reintroduce it as an optional shorthand instead. Signed-off-by: clux <sszynrae@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #945 +/- ##
==========================================
- Coverage 72.47% 72.43% -0.04%
==========================================
Files 64 64
Lines 4399 4412 +13
==========================================
+ Hits 3188 3196 +8
- Misses 1211 1216 +5
|
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
Hm, not sure I see a lot of value in exposing |
Well, that's also one of the reasons i exposed obj.name_or_generatename().unwrap_or_else(||"(unnamed)") or whatever constant they want. i think the majority use case for the _any case is going to be quick logging rather than precise defaults, so am not super keen on making the weird use case a mandatory thing to think about. empty string returned on both missing is kind of ok when we are being imprecise - as implied by the _any suffix. |
maybe a |
Yeah, I agree that it's kind of a weird special case. I just don't see what other use case there is where you don't care at all about the distinction between name and genname. |
probably not the greatest use case for it Signed-off-by: clux <sszynrae@gmail.com>
Yeah, that's a good point. I have removed |
left the eq/partialeq ones, those felt a bit more unclear if they were good. Signed-off-by: clux <sszynrae@gmail.com>
Both the warned-about types should be safe to derive |
Signed-off-by: clux <sszynrae@gmail.com>
Due to the general awkwardness of having a potentially panicking
::name()
method front and center even though it is generally safe to use. See #634 for initial discussion, and #942 for the most recent confusion.This adds:
ResourceExt::name_any
providing a short & safe drop-in replacement forname()
(can return empty string) for loggersResourceExt::name_unchecked
where we explicitly want a crash on missing name (like internally in runtime::reflector)Now the relevant docs from
ResourceExt
looks like:Then ran a lot of
fastmod
to replace in the codebase. Have set the removal of ::name to the deprecation length we used for runtime's try_flattens; removing on the 4th minor.Plan
Long term we can remove
.name()
and maybe reintroduce it later as an option shorthand for.meta().name
instead.edited out comments
It is also possible we can make
::name
a non-panicing variant:Not sure if this is wise. But it would be nice to have something short for all the standard log gunk where this stuff is inevitably used most of the time.
EDIT: this is added under
::name_any
EDIT: removed
ResourceExt::name_or_generatename
.