@@ -232,26 +232,23 @@ public extension NSAttributedString.Key {
232232 static let paragraphBreak : NSAttributedString . Key = . init( " MTASParagraphBreak " )
233233}
234234
235- public class MarkdownElementAttributes : NSObject , NSCopying {
235+ public struct MarkdownElementAttributes : Equatable , Hashable , CustomStringConvertible {
236236 private var storage : [ MarkupType : MarkdownElementAttribute ]
237237
238238 public init ( _ attributes: [ MarkupType : MarkdownElementAttribute ] = [ : ] ) {
239239 self . storage = attributes
240- super. init ( )
241240 }
242241
243- public override func isEqual( _ object: Any ? ) -> Bool {
244- guard let other = object as? MarkdownElementAttributes else { return false }
245- return self . storage == other. storage
242+ static public func == ( lhs: MarkdownElementAttributes , rhs: MarkdownElementAttributes ) -> Bool {
243+ return lhs. storage == rhs. storage
246244 }
247245
248- public override var hash : Int {
249- return storage . hashValue
246+ public func hash( into hasher : inout Hasher ) {
247+ hasher . combine ( storage )
250248 }
251249
252- public override var description : String {
253- let addr = " \( Unmanaged . passUnretained ( self ) . toOpaque ( ) ) "
254- return " <MarkdownElementAttributes: \( addr) > \( storage. description) "
250+ public var description : String {
251+ return " <MarkdownElementAttributes> \( storage. description) "
255252 }
256253
257254 public var allAttributes : [ ( MarkupType , MarkdownElementAttribute ) ] {
@@ -272,11 +269,11 @@ public extension MarkdownElementAttributes {
272269 return storage [ key]
273270 }
274271
275- func add( _ mdElAttr: MarkdownElementAttribute ) {
272+ mutating func add( _ mdElAttr: MarkdownElementAttribute ) {
276273 storage [ mdElAttr. elementType] = mdElAttr
277274 }
278275
279- func remove( _ type: MarkupType ) {
276+ mutating func remove( _ type: MarkupType ) {
280277 storage [ type] = nil
281278 }
282279
@@ -335,7 +332,7 @@ public extension StringAttrs {
335332 }
336333
337334 mutating func addMarkdownElementAttr( _ attr: MarkdownElementAttribute ) {
338- let d = ( self [ . markdownElements] as? MarkdownElementAttributes ) ?? MarkdownElementAttributes ( )
335+ var d = ( self [ . markdownElements] as? MarkdownElementAttributes ) ?? MarkdownElementAttributes ( )
339336 d. add ( attr)
340337 self [ . markdownElements] = d
341338 }
0 commit comments