You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One issue with this approach is that the generated Raw struct is reused by both the Read and Write structs, which means it needs to contain all properties of both structs. However, that allows a developer to write something like write.raw.en = 1, which is unsafe because en is supposed to be read-only.
Instead, I propose that the properties of the Raw struct be merged into the Read/Write structs. The new properties could be prefixed with $, similar to property wrappers, to denote that the properties are just a different view on the non-prefixed properties.
cr1.modify{(read, write)inprint(read.$en)
write.$clken =1
write.$en =1 // compile error: `$en` does not exist
}
(If #70 is accepted, this change would also make the Read/Write structs less awkward by avoiding having similarly-named rawValue and raw properties.)
The text was updated successfully, but these errors were encountered:
(I originally proposed this change here.)
The
@Register
macro generates 3 structs:Read
,Write
, andRaw
. TheRaw
struct is accessed through the.raw
property of theRead
andWrite
structs:One issue with this approach is that the generated
Raw
struct is reused by both theRead
andWrite
structs, which means it needs to contain all properties of both structs. However, that allows a developer to write something likewrite.raw.en = 1
, which is unsafe becauseen
is supposed to be read-only.Instead, I propose that the properties of the
Raw
struct be merged into theRead
/Write
structs. The new properties could be prefixed with$
, similar to property wrappers, to denote that the properties are just a different view on the non-prefixed properties.(If #70 is accepted, this change would also make the
Read
/Write
structs less awkward by avoiding having similarly-namedrawValue
andraw
properties.)The text was updated successfully, but these errors were encountered: