Skip to content

Commit eaa0666

Browse files
author
Pouya Yarandi
committed
Some minor changes in comments
1 parent f01f29c commit eaa0666

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Sources/SwiftProtobuf/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ add_library(SwiftProtobuf
33
AnyMessageStorage.swift
44
AnyUnpackError.swift
55
api.pb.swift
6+
Applying.swift
67
BinaryDecoder.swift
78
BinaryDecodingError.swift
89
BinaryDecodingOptions.swift
@@ -49,6 +50,7 @@ add_library(SwiftProtobuf
4950
JSONScanner.swift
5051
MathUtils.swift
5152
Message+AnyAdditions.swift
53+
Message+Applying.swift
5254
Message+BinaryAdditions.swift
5355
Message+JSONAdditions.swift
5456
Message+JSONArrayAdditions.swift

Sources/SwiftProtobuf/Message+Applying.swift

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,39 @@
1212
///
1313
// -----------------------------------------------------------------------------
1414

15-
public extension Message {
15+
/// Applying a value to a field of the message by its field number
16+
extension Message {
1617

17-
/// Applies a value for a specific `fieldNumber` of the message
18-
/// and returns a copy of it.
18+
/// Applies a value for a specific `fieldNumber` of the message and returns a copy
19+
/// of the original message.
1920
///
2021
/// - Parameters:
2122
/// - value: The value to be applied.
2223
/// - fieldNumber: Protobuf index of the field that the value should be applied for.
2324
/// - Returns: A copy of the message with applied value.
24-
func applying(_ value: Any, for fieldNumber: Int) throws -> Self {
25+
public func applying(
26+
_ value: Any,
27+
for fieldNumber: Int
28+
) throws -> Self {
2529
var copy = self
2630
try copy.apply(value, for: fieldNumber)
2731
return copy
2832
}
2933

30-
/// Applies a value for a specific `fieldNumber` of the message without
31-
/// making a copy. This method mutates the original message.
34+
/// Applies a value for a specific `fieldNumber` of the message without making a
35+
/// copy. This method mutates the original message.
3236
///
3337
/// - Parameters:
3438
/// - value: The value to be applied.
3539
/// - fieldNumber: Protobuf index of the field that the value should be applied for.
36-
mutating func apply(_ value: Any, for fieldNumber: Int) throws {
37-
var decoder = ApplyingDecoder(fieldNumber: fieldNumber, value: value)
40+
public mutating func apply(
41+
_ value: Any,
42+
for fieldNumber: Int
43+
) throws {
44+
var decoder = ApplyingDecoder(
45+
fieldNumber: fieldNumber,
46+
value: value
47+
)
3848
try decodeMessage(decoder: &decoder)
3949
}
4050
}

0 commit comments

Comments
 (0)