diff --git a/README.md b/README.md index 7a6cf3e..dd7fe54 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ Example: ```swift -@MutableCopy +@MutatedCopy struct SomeStruct: Equatable { let id = "const uuidstring ;)" var intValue: Int @@ -176,7 +176,7 @@ struct SomeStruct: Equatable { } extension SomeStruct { - func mutableCopy(configuring: (inout SomeStruct) throws -> Void) rethrows -> SomeStruct { + func mutatedCopy(configuring: (_ it: inout SomeStruct) throws -> Void) rethrows -> SomeStruct { var mutableCopy = self try configuring(&mutableCopy) @@ -187,7 +187,7 @@ extension SomeStruct { // usage let exampleStruct = SomeStruct(parameter1: 0, parameter2: false) -let exampleStructModified = exampleStruct.mutableCopy { +let exampleStructModified = exampleStruct.mutatedCopy { $0.intValue = 42 $0.boolValue = true } diff --git a/Sources/VACopyWith/VACopyWith.swift b/Sources/VACopyWith/VACopyWith.swift index aa215ee..e4af60f 100644 --- a/Sources/VACopyWith/VACopyWith.swift +++ b/Sources/VACopyWith/VACopyWith.swift @@ -1,4 +1,4 @@ @attached(extension, names: arbitrary) public macro CopyWith() = #externalMacro(module: "VACopyWithMacros", type: "VACopyWithMacro") @attached(extension, names: arbitrary) -public macro MutableCopy() = #externalMacro(module: "VACopyWithMacros", type: "VAMutableCopyMacro") +public macro MutatedCopy() = #externalMacro(module: "VACopyWithMacros", type: "VAMutatedCopyMacro") diff --git a/Sources/VACopyWithClient/main.swift b/Sources/VACopyWithClient/main.swift index baf13a1..11d12e6 100644 --- a/Sources/VACopyWithClient/main.swift +++ b/Sources/VACopyWithClient/main.swift @@ -39,7 +39,7 @@ assert(value2.copyWith(parameter1: [2, 3, 4]) == SomeStruct2(parameter1: [2, 3, assert(value2.copyWith(parameter2: .value("new string")) == SomeStruct2(parameter2: "new string")) assert(value2.copyWith(parameter2: .nil) == SomeStruct2(parameter2: nil)) -@MutableCopy +@MutatedCopy struct SomeStruct3: Equatable { let id = "const uuidstring ;)" var parameter1: Int @@ -47,7 +47,7 @@ struct SomeStruct3: Equatable { } let value3 = SomeStruct3(parameter1: 0, parameter2: false) -assert(value3.mutableCopy { +assert(value3.mutatedCopy { $0.parameter1 = 42 $0.parameter2 = true } == SomeStruct3(parameter1: 42, parameter2: true)) diff --git a/Sources/VACopyWithMacros/VACopyWithMacro.swift b/Sources/VACopyWithMacros/VACopyWithMacro.swift index 4507c72..110834b 100644 --- a/Sources/VACopyWithMacros/VACopyWithMacro.swift +++ b/Sources/VACopyWithMacros/VACopyWithMacro.swift @@ -96,7 +96,7 @@ public struct VACopyWithMacro: ExtensionMacro { } } -public struct VAMutableCopyMacro: ExtensionMacro { +public struct VAMutatedCopyMacro: ExtensionMacro { public static func expansion( of node: AttributeSyntax, @@ -117,7 +117,7 @@ public struct VAMutableCopyMacro: ExtensionMacro { return [ ExtensionDeclSyntax(modifiers: decl.modifiers.accessModifier, extendedType: type) { """ - func mutableCopy(configuring: (inout \(type)) throws -> Void) rethrows -> \(type) { + func mutatedCopy(configuring: (_ it: inout \(type)) throws -> Void) rethrows -> \(type) { var mutableCopy = self try configuring(&mutableCopy) @@ -133,6 +133,6 @@ public struct VAMutableCopyMacro: ExtensionMacro { struct VACopyWithPlugin: CompilerPlugin { let providingMacros: [Macro.Type] = [ VACopyWithMacro.self, - VAMutableCopyMacro.self, + VAMutatedCopyMacro.self, ] } diff --git a/Tests/VACopyWithTests/VACopyWithTests+MutableCopy.swift b/Tests/VACopyWithTests/VACopyWithTests+MutatedCopy.swift similarity index 81% rename from Tests/VACopyWithTests/VACopyWithTests+MutableCopy.swift rename to Tests/VACopyWithTests/VACopyWithTests+MutatedCopy.swift index 64a9728..03b3029 100644 --- a/Tests/VACopyWithTests/VACopyWithTests+MutableCopy.swift +++ b/Tests/VACopyWithTests/VACopyWithTests+MutatedCopy.swift @@ -15,10 +15,10 @@ import VACopyWithMacros extension VACopyWithTests { - func test_mutableCopy_struct_extension() throws { + func test_mutated_struct_extension() throws { assertMacroExpansion( """ - @MutableCopy + @MutatedCopy struct SomeStruct { } """, @@ -30,10 +30,10 @@ extension VACopyWithTests { ) } - func test_mutableCopy_struct_failure() throws { + func test_mutated_struct_failure() throws { assertMacroExpansion( """ - @MutableCopy + @MutatedCopy class SomeStruct { let (a, b): (Int, Int) } @@ -48,10 +48,10 @@ extension VACopyWithTests { ) } - func test_mutableCopy_struct_let() throws { + func test_mutated_struct_let() throws { assertMacroExpansion( """ - @MutableCopy + @MutatedCopy struct SomeStruct { let a: Int } @@ -65,10 +65,10 @@ extension VACopyWithTests { ) } - func test_mutableCopy_struct_var() throws { + func test_mutated_struct_var() throws { assertMacroExpansion( """ - @MutableCopy + @MutatedCopy struct SomeStruct { var a: Int } @@ -79,7 +79,7 @@ extension VACopyWithTests { } extension SomeStruct { - func mutableCopy(configuring: (inout SomeStruct) throws -> Void) rethrows -> SomeStruct { + func mutatedCopy(configuring: (_ it: inout SomeStruct) throws -> Void) rethrows -> SomeStruct { var mutableCopy = self try configuring(&mutableCopy) diff --git a/Tests/VACopyWithTests/VACopyWithTests.swift b/Tests/VACopyWithTests/VACopyWithTests.swift index 5b5e695..444028e 100644 --- a/Tests/VACopyWithTests/VACopyWithTests.swift +++ b/Tests/VACopyWithTests/VACopyWithTests.swift @@ -9,7 +9,7 @@ import VACopyWithMacros let testMacros: [String: Macro.Type] = [ "CopyWith": VACopyWithMacro.self, - "MutableCopy": VAMutableCopyMacro.self, + "MutatedCopy": VAMutatedCopyMacro.self, ] #endif