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
Register fields are required to specify a type but common usage will use an as: parameter. This means that the type that is written for a given field is not really used. Instead it is a type information for storing via an un-inhabited enumeration.
@ReadWrite(bits: 0..<3, as: TestValues.self)
public var someField: Test
this expands in the register and the field to:
public var someField: Test {
get {
fatalError()
}
}
public enum Test: ContiguousBitField {
public typealias Storage = UInt8
public static let bitRange = 0 ..< 3
}
instead it could be more canonically written in standard swift parlance as:
@ReadWrite(bits: 0..<3)
public var someField: TestValues
which can expand (by using the name of the field instead of the name of the type)
public enum SomeField: ContiguousBitField {
public typealias Storage = UInt8
public static let bitRange = 0 ..< 3
}
The text was updated successfully, but these errors were encountered:
I agree! Swapping the projected type and the descriptor type would make it feel more natural.
As I wrote here, the register field macro could even have a generatedDescriptorType property to allow the developer to specify the generated type name. (It would be nice for the macro to automatically generate a name if the macro property was omitted though.)
Register fields are required to specify a type but common usage will use an
as:
parameter. This means that the type that is written for a given field is not really used. Instead it is a type information for storing via an un-inhabited enumeration.this expands in the register and the field to:
instead it could be more canonically written in standard swift parlance as:
which can expand (by using the name of the field instead of the name of the type)
The text was updated successfully, but these errors were encountered: