@@ -1108,9 +1108,9 @@ pub fn takeVarInt(r: *Reader, comptime Int: type, endian: std.builtin.Endian, n:
1108
1108
/// Asserts the buffer was initialized with a capacity at least `@sizeOf(T)`.
1109
1109
///
1110
1110
/// See also:
1111
- /// * `peekStructReference `
1111
+ /// * `peekStructPointer `
1112
1112
/// * `takeStruct`
1113
- pub fn takeStructReference (r : * Reader , comptime T : type ) Error ! * align (1 ) T {
1113
+ pub fn takeStructPointer (r : * Reader , comptime T : type ) Error ! * align (1 ) T {
1114
1114
// Only extern and packed structs have defined in-memory layout.
1115
1115
comptime assert (@typeInfo (T ).@"struct" .layout != .auto );
1116
1116
return @ptrCast (try r .takeArray (@sizeOf (T )));
@@ -1122,9 +1122,9 @@ pub fn takeStructReference(r: *Reader, comptime T: type) Error!*align(1) T {
1122
1122
/// Asserts the buffer was initialized with a capacity at least `@sizeOf(T)`.
1123
1123
///
1124
1124
/// See also:
1125
- /// * `takeStructReference `
1125
+ /// * `takeStructPointer `
1126
1126
/// * `peekStruct`
1127
- pub fn peekStructReference (r : * Reader , comptime T : type ) Error ! * align (1 ) T {
1127
+ pub fn peekStructPointer (r : * Reader , comptime T : type ) Error ! * align (1 ) T {
1128
1128
// Only extern and packed structs have defined in-memory layout.
1129
1129
comptime assert (@typeInfo (T ).@"struct" .layout != .auto );
1130
1130
return @ptrCast (try r .peekArray (@sizeOf (T )));
@@ -1136,14 +1136,14 @@ pub fn peekStructReference(r: *Reader, comptime T: type) Error!*align(1) T {
1136
1136
/// when `endian` is comptime-known and matches the host endianness.
1137
1137
///
1138
1138
/// See also:
1139
- /// * `takeStructReference `
1139
+ /// * `takeStructPointer `
1140
1140
/// * `peekStruct`
1141
1141
pub inline fn takeStruct (r : * Reader , comptime T : type , endian : std.builtin.Endian ) Error ! T {
1142
1142
switch (@typeInfo (T )) {
1143
1143
.@"struct" = > | info | switch (info .layout ) {
1144
1144
.auto = > @compileError ("ill-defined memory layout" ),
1145
1145
.@"extern" = > {
1146
- var res = (try r .takeStructReference (T )).* ;
1146
+ var res = (try r .takeStructPointer (T )).* ;
1147
1147
if (native_endian != endian ) std .mem .byteSwapAllFields (T , & res );
1148
1148
return res ;
1149
1149
},
@@ -1162,13 +1162,13 @@ pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia
1162
1162
///
1163
1163
/// See also:
1164
1164
/// * `takeStruct`
1165
- /// * `peekStructReference `
1165
+ /// * `peekStructPointer `
1166
1166
pub inline fn peekStruct (r : * Reader , comptime T : type , endian : std.builtin.Endian ) Error ! T {
1167
1167
switch (@typeInfo (T )) {
1168
1168
.@"struct" = > | info | switch (info .layout ) {
1169
1169
.auto = > @compileError ("ill-defined memory layout" ),
1170
1170
.@"extern" = > {
1171
- var res = (try r .peekStructReference (T )).* ;
1171
+ var res = (try r .peekStructPointer (T )).* ;
1172
1172
if (native_endian != endian ) std .mem .byteSwapAllFields (T , & res );
1173
1173
return res ;
1174
1174
},
@@ -1557,27 +1557,27 @@ test takeVarInt {
1557
1557
try testing .expectError (error .EndOfStream , r .takeVarInt (u16 , .little , 1 ));
1558
1558
}
1559
1559
1560
- test takeStructReference {
1560
+ test takeStructPointer {
1561
1561
var r : Reader = .fixed (&.{ 0x12 , 0x00 , 0x34 , 0x56 });
1562
1562
const S = extern struct { a : u8 , b : u16 };
1563
1563
switch (native_endian ) {
1564
- .little = > try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x5634 }), (try r .takeStructReference (S )).* ),
1565
- .big = > try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x3456 }), (try r .takeStructReference (S )).* ),
1564
+ .little = > try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x5634 }), (try r .takeStructPointer (S )).* ),
1565
+ .big = > try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x3456 }), (try r .takeStructPointer (S )).* ),
1566
1566
}
1567
- try testing .expectError (error .EndOfStream , r .takeStructReference (S ));
1567
+ try testing .expectError (error .EndOfStream , r .takeStructPointer (S ));
1568
1568
}
1569
1569
1570
- test peekStructReference {
1570
+ test peekStructPointer {
1571
1571
var r : Reader = .fixed (&.{ 0x12 , 0x00 , 0x34 , 0x56 });
1572
1572
const S = extern struct { a : u8 , b : u16 };
1573
1573
switch (native_endian ) {
1574
1574
.little = > {
1575
- try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x5634 }), (try r .peekStructReference (S )).* );
1576
- try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x5634 }), (try r .peekStructReference (S )).* );
1575
+ try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x5634 }), (try r .peekStructPointer (S )).* );
1576
+ try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x5634 }), (try r .peekStructPointer (S )).* );
1577
1577
},
1578
1578
.big = > {
1579
- try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x3456 }), (try r .peekStructReference (S )).* );
1580
- try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x3456 }), (try r .peekStructReference (S )).* );
1579
+ try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x3456 }), (try r .peekStructPointer (S )).* );
1580
+ try testing .expectEqual (@as (S , .{ .a = 0x12 , .b = 0x3456 }), (try r .peekStructPointer (S )).* );
1581
1581
},
1582
1582
}
1583
1583
}
0 commit comments