From ca7e6b274b190ef152373ffcca8510bf50ef7e5c Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Fri, 28 May 2021 21:12:22 +0200 Subject: Use `.{ ... }` for struct init where possible --- src/main.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 23f0e05..3ee70cc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -173,14 +173,14 @@ pub const SeedKeyPair = struct { } pub fn intoPublicKey(self: *const Self) PublicKey { - return PublicKey{ + return .{ .role = self.role, .key = self.kp.public_key, }; } pub fn intoPrivateKey(self: *const Self) PrivateKey { - return PrivateKey{ .kp = self.kp }; + return .{ .kp = self.kp }; } pub fn wipe(self: *Self) void { @@ -205,7 +205,7 @@ pub const PublicKey = struct { } pub fn fromRawPublicKey(role: Role, raw_key: *const [Ed25519.public_length]u8) Self { - return Self{ .role = role, .key = raw_key.* }; + return .{ .role = role, .key = raw_key.* }; } pub fn publicKeyText(self: *const Self) text_public { @@ -232,22 +232,22 @@ pub const PrivateKey = struct { defer decoded.wipe(); // gets copied if (decoded.prefix[0] != prefix_byte_private) return error.InvalidPrivateKey; - return PrivateKey{ .kp = Ed25519.KeyPair.fromSecretKey(decoded.data) }; + return Self{ .kp = Ed25519.KeyPair.fromSecretKey(decoded.data) }; } pub fn fromRawPrivateKey(raw_key: *const [Ed25519.secret_length]u8) Self { - return Self{ .kp = Ed25519.KeyPair.fromSecretKey(raw_key.*) }; + return .{ .kp = Ed25519.KeyPair.fromSecretKey(raw_key.*) }; } pub fn intoSeedKeyPair(self: *const Self, role: Role) SeedKeyPair { - return SeedKeyPair{ + return .{ .role = role, .kp = self.kp, }; } pub fn intoPublicKey(self: *const Self, role: Role) PublicKey { - return PublicKey{ + return .{ .role = role, .key = self.kp.public_key, }; -- cgit v1.2.3