We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Similar to automatic conformance for Codable, Pack should be able to generate automatic conformance to the Packable protocol using attached macros.
Codable
Packable
For example, the following type:
struct Color { let name: String var red: Double var green: Double var blue: Double var alpha: Double = 1.0 }
Should be able to attach a macro such as @packable to the structure, and the implementation would be automatically generated.
@packable
@packable struct Color { let name: String var red: Double var green: Double var blue: Double var alpha: Double = 1.0 // - - - - - - - - - - - - - - Generated - - - - - - - - - - - - - - init(from unpacker: inout Unpacker) throws { self.name = try unpacker.unpack(String.self, using: .utf16) self.red = try unpacker.unpack(Double.self) self.green = try unpacker.unpack(Double.self) self.blue = try unpacker.unpack(Double.self) self.alpha = try unpacker.unpack(Double.self) } func pack(to packer: inout Packer) throws { try packer.pack(name, using: .utf16) try packer.pack(red) try packer.pack(green) try packer.pack(blue) try packer.pack(alpha) } // - - - - - - - - - - - - - - Generated - - - - - - - - - - - - - - }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Similar to automatic conformance for
Codable
, Pack should be able to generate automatic conformance to thePackable
protocol using attached macros.For example, the following type:
Should be able to attach a macro such as
@packable
to the structure, and the implementation would be automatically generated.The text was updated successfully, but these errors were encountered: