Skip to content

Commit

Permalink
Add CustomStringConvertible conformance to integers
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 8, 2024
1 parent d45e9c4 commit ea9c036
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Bluetooth/UInt128.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ extension Bluetooth.UInt128: CustomStringConvertible {
if #available(macOS 15, iOS 18, watchOS 11, tvOS 18, visionOS 2, *) {
return Swift.UInt128(self).description
} else {
return hexadecimal
return "0x" + hexadecimal
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions Sources/Bluetooth/UInt24.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ extension UInt24: ExpressibleByIntegerLiteral {
}
}

// MARK: - CustomStringConvertible

extension UInt24: CustomStringConvertible {

public var description: String {
UInt32(self).description
}
}

// MARK: - Integer Conversion

public extension UInt24 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Bluetooth/UInt256.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ extension UInt256: ExpressibleByIntegerLiteral {
self = UInt256(bigEndian: UInt256(bytes: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, bytes.0, bytes.1, bytes.2, bytes.3, bytes.4, bytes.5, bytes.6, bytes.7)))
}
}

// MARK: - CustomStringConvertible

extension UInt256: CustomStringConvertible { }
9 changes: 9 additions & 0 deletions Sources/Bluetooth/UInt40.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ extension UInt40: ExpressibleByIntegerLiteral {
}
}

// MARK: - CustomStringConvertible

extension UInt40: CustomStringConvertible {

public var description: String {
UInt64(self).description
}
}

// MARK: - Integer Conversion

public extension UInt40 {
Expand Down
9 changes: 9 additions & 0 deletions Sources/Bluetooth/UInt48.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ extension UInt48: ExpressibleByIntegerLiteral {
}
}

// MARK: - CustomStringConvertible

extension UInt48: CustomStringConvertible {

public var description: String {
UInt64(self).description
}
}

// MARK: - Integer Conversion

public extension UInt48 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Bluetooth/UInt512.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ extension UInt512: ExpressibleByIntegerLiteral {
self = UInt512(bigEndian: UInt512(bytes: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, bytes.0, bytes.1, bytes.2, bytes.3, bytes.4, bytes.5, bytes.6, bytes.7)))
}
}

// MARK: - CustomStringConvertible

extension UInt512: CustomStringConvertible { }

0 comments on commit ea9c036

Please sign in to comment.