|
12 | 12 | ///
|
13 | 13 | // -----------------------------------------------------------------------------
|
14 | 14 |
|
15 |
| -public extension Message { |
| 15 | +/// Applying a value to a field of the message by its field number |
| 16 | +extension Message { |
16 | 17 |
|
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. |
19 | 20 | ///
|
20 | 21 | /// - Parameters:
|
21 | 22 | /// - value: The value to be applied.
|
22 | 23 | /// - fieldNumber: Protobuf index of the field that the value should be applied for.
|
23 | 24 | /// - 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 { |
25 | 29 | var copy = self
|
26 | 30 | try copy.apply(value, for: fieldNumber)
|
27 | 31 | return copy
|
28 | 32 | }
|
29 | 33 |
|
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. |
32 | 36 | ///
|
33 | 37 | /// - Parameters:
|
34 | 38 | /// - value: The value to be applied.
|
35 | 39 | /// - 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 | + ) |
38 | 48 | try decodeMessage(decoder: &decoder)
|
39 | 49 | }
|
40 | 50 | }
|
0 commit comments