Skip to content

Commit ff94963

Browse files
authored
Declare Data.period property is a way compatitible with + operator (#6149)
Cannot use `extension Data` if `period` is going to be used with `+` operator via leading-dot syntax, for example: `Data(...) + .period` because `+` is declared as `(Self, Other) -> Self` where `Other: RangeReplaceableCollection, Other.Element == Self.Element` which means that `.period` couldn't get `Data` inferred from the first argument.
1 parent ceb9050 commit ff94963

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/PackageCollectionsSigning/Utilities/Utilities.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ extension UInt8 {
2727
}
2828
}
2929

30-
extension Data {
30+
/// Cannot use `extension Data` if `period` is going to be used with
31+
/// `+` operator via leading-dot syntax, for example: `Data(...) + .period`
32+
/// because `+` is declared as `(Self, Other) -> Self` where
33+
/// `Other: RangeReplaceableCollection, Other.Element == Self.Element`
34+
/// which means that `.period` couldn't get `Data` inferred from the first argument.
35+
extension RangeReplaceableCollection where Self == Data {
3136
static var period: Data {
3237
Data([UInt8.period])
3338
}

0 commit comments

Comments
 (0)