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
Implement "fieldset" optimization for record types #2474
Comments
I learn from Rust 0.5 documentation that record type is gone. Now you call it struct type. Is that correct? |
@pcdinh Not exactly. Record types and struct types are different. Two record types can be considered the same if the names and types of all their fields are identical and in the same order (that is: they're structurally the same). A struct type has a name that's part of its identity in addition to its fields and types, and two struct types are only considered the same if they refer to the struct type with the same name. For example, if you write |
Thanks for your clarification. What I read from Rust docs is that I am recommended to use structural type instead of record type because record expression and record types will be removed in a future version. http://static.rust-lang.org/doc/rust.html#record-expressions Therefore I think that they are identical and can be used interchangeably. It turns out that they are different. |
I think most people won't see much difference between struct types and record types in practice. There's just the one caveat that I thought I'd mention. |
Now that structural records have been removed and strings are interned, I |
also forward --manifest-path to 'cargo metadata' and then I went on to refactor the argument flag splitting thing a bit, and, uh, that snowballed...
Currently, record field names are stored as strings in the structural types. This is inefficient; every time we want to define a record in the type table we must perform a string comparison against every field name. Instead we can simply intern an entire "fieldset" -- a list of interned field strings, compared by pointer value only -- as we come across it. Then ty_rec would be something like
fieldset, [mt]
.The text was updated successfully, but these errors were encountered: