As Claus Jørgensen’s reply says, you can not “override” the protocol witness description
in your personal extension.
If the entire objective of doing that is simply so you possibly can instantly print
the information, there may be an alternate.
You see, print
would not simply use CustomStringConvertible.description
to print values. print
simply makes use of String.init(describing:)
to work out what string to print, and String.init(describing:)
would first verify if the worth conforms to TextOutputStreamable
, earlier than it checks for CustomStringConvertible
conformance.
Fortunately, Knowledge
would not conform to TextOutputStreamable
, so you possibly can write
extension Knowledge : @retroactive TextOutputStreamable {
public func write(to focus on: inout Goal) the place Goal : TextOutputStream {
goal.write(base64EncodedString())
}
}
That stated, this could be an issue when in some future model Knowledge
does conform to TextOutputStreamable
. Due to this fact, the most effective factor to do is to chew the bullet and explicitly write information.base64EncodedString()
in your print
calls.