[swift-users] protocol definition question

Frank Swarbrick fswarbrick at gmail.com
Wed Dec 13 23:42:02 CST 2017


I have the following:

 

public protocol RawBits: CustomStringConvertible, Collection {

    associatedtype RawValue

    var rawValue: RawValue  { get set }

}

 

extension RawBits where RawValue: FixedWidthInteger, RawValue:
UnsignedInteger {

    [...fields and methods are defined here...]

}

 

struct RawBits8: RawBits {

    var rawValue: UInt8

}

 

This all works fine.

Now I want to be able to define an extension to which the following would
conform:

 

struct RawBitsX: RawBits {

    var rawValue: [UInt8]

}

 

rawValue is now an array rather than a simple type.  I can't for the life of
me figure out how to indicate this in the 'where' clause of an extension to
RawBits.  Can this be done?  How?

 

Thanks for any assistance,

Frank

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171213/8a43d0fb/attachment.html>


More information about the swift-users mailing list