-
Notifications
You must be signed in to change notification settings - Fork 83
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
Make fields on common structs pub
#2081
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2081 +/- ##
==========================================
- Coverage 58.51% 58.41% -0.11%
==========================================
Files 285 285
Lines 21343 21289 -54
Branches 420 420
==========================================
- Hits 12489 12435 -54
Misses 8849 8849
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I like this! I wonder if rust-lang/rust#105077 might be of use. |
I'm really looking forward to that RFC, thanks for linking this here! |
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'm not really a fan of making the fields on EntityMetadata
pub, the metadata shouldn't be mutable (and while I appreciate we can handle that by just not having const mut entity_metadata ...
, not having any way of setting inner fields after construction is just more idiomatic and consistent with the rest of our code).
I don't think the gains in two functions of having field: x
on the constructor is worth it, that explicitness is provided by IDEs with parameter hints already, and all of the types are distinct so you can't put them in in the wrong order.
We also don't have a need (to my knowledge) of destructuring these
Thanks, @Alfred-Mountfield, I appreciate the concern. I have reverted changes to |
😎 Merged successfully (details). |
🌟 What is the purpose of this PR?
For the same reason as blockprotocol/blockprotocol#987 this PR makes structs, which are only a collection of information (like
OntologyVertexId
, orEntitMetadata
) publicly accessible. With the linked PR it's also possible to properly implementFrom
implementations forVersionedUri
.These changes makes a few accesses a little bit more verbose when otherwise chaining is possible, however, in other cases, this greatly improves readability, especially when type hints are available.
I planned to do these changes as a drive-by to my next PR but have split the changes off to make reviewing easier.
🚫 Blocked by
VersionedUri
public blockprotocol/blockprotocol#987🔍 What does this change?
Please see the list of commits to see the changes
This PR also implements
FromSql
for more types, which previously we didn't because from just looking at the code (without typehints), it was not possible to see, if the parameters returned fromrow.get(N)
were passed to the correct location. With these changes it's now required to type the parameter explicitly, so it's easy to check if a call was made correctly (the parameter passed toget()
can't be checked at compile time).Example: