swift-mmio icon indicating copy to clipboard operation
swift-mmio copied to clipboard

It would be useful to have common bit sizes of unsigned integers for BitFieldProjectables

Open phausler opened this issue 1 year ago • 5 comments

UInt8, UInt16, UInt32, and UInt64 are common field member types (when not enumerations or option sets).

extension UInt8: BitFieldProjectable {
  public static var bitWidth: Int { 8 }

  public init<Storage>(storage: Storage)
  where Storage: FixedWidthInteger & UnsignedInteger {
    self.init(storage)
  }

  public func storage<Storage>(_: Storage.Type) -> Storage
  where Storage: FixedWidthInteger & UnsignedInteger {
    Storage(self)
  }
}

phausler avatar Nov 18 '23 18:11 phausler