@@ -1108,9 +1108,9 @@ pub fn takeVarInt(r: *Reader, comptime Int: type, endian: std.builtin.Endian, n:
11081108/// Asserts the buffer was initialized with a capacity at least `@sizeOf(T)`.
11091109///
11101110/// See also:
1111- /// * `peekStructReference `
1111+ /// * `peekStructPointer `
11121112/// * `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 {
11141114 // Only extern and packed structs have defined in-memory layout.
11151115 comptime assert (@typeInfo (T ).@"struct" .layout != .auto );
11161116 return @ptrCast (try r .takeArray (@sizeOf (T )));
@@ -1122,9 +1122,9 @@ pub fn takeStructReference(r: *Reader, comptime T: type) Error!*align(1) T {
11221122/// Asserts the buffer was initialized with a capacity at least `@sizeOf(T)`.
11231123///
11241124/// See also:
1125- /// * `takeStructReference `
1125+ /// * `takeStructPointer `
11261126/// * `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 {
11281128 // Only extern and packed structs have defined in-memory layout.
11291129 comptime assert (@typeInfo (T ).@"struct" .layout != .auto );
11301130 return @ptrCast (try r .peekArray (@sizeOf (T )));
@@ -1136,14 +1136,14 @@ pub fn peekStructReference(r: *Reader, comptime T: type) Error!*align(1) T {
11361136/// when `endian` is comptime-known and matches the host endianness.
11371137///
11381138/// See also:
1139- /// * `takeStructReference `
1139+ /// * `takeStructPointer `
11401140/// * `peekStruct`
11411141pub inline fn takeStruct (r : * Reader , comptime T : type , endian : std.builtin.Endian ) Error ! T {
11421142 switch (@typeInfo (T )) {
11431143 .@"struct" = > | info | switch (info .layout ) {
11441144 .auto = > @compileError ("ill-defined memory layout" ),
11451145 .@"extern" = > {
1146- var res = (try r .takeStructReference (T )).* ;
1146+ var res = (try r .takeStructPointer (T )).* ;
11471147 if (native_endian != endian ) std .mem .byteSwapAllFields (T , & res );
11481148 return res ;
11491149 },
@@ -1162,13 +1162,13 @@ pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia
11621162///
11631163/// See also:
11641164/// * `takeStruct`
1165- /// * `peekStructReference `
1165+ /// * `peekStructPointer `
11661166pub inline fn peekStruct (r : * Reader , comptime T : type , endian : std.builtin.Endian ) Error ! T {
11671167 switch (@typeInfo (T )) {
11681168 .@"struct" = > | info | switch (info .layout ) {
11691169 .auto = > @compileError ("ill-defined memory layout" ),
11701170 .@"extern" = > {
1171- var res = (try r .peekStructReference (T )).* ;
1171+ var res = (try r .peekStructPointer (T )).* ;
11721172 if (native_endian != endian ) std .mem .byteSwapAllFields (T , & res );
11731173 return res ;
11741174 },
@@ -1557,27 +1557,27 @@ test takeVarInt {
15571557 try testing .expectError (error .EndOfStream , r .takeVarInt (u16 , .little , 1 ));
15581558}
15591559
1560- test takeStructReference {
1560+ test takeStructPointer {
15611561 var r : Reader = .fixed (&.{ 0x12 , 0x00 , 0x34 , 0x56 });
15621562 const S = extern struct { a : u8 , b : u16 };
15631563 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 )).* ),
15661566 }
1567- try testing .expectError (error .EndOfStream , r .takeStructReference (S ));
1567+ try testing .expectError (error .EndOfStream , r .takeStructPointer (S ));
15681568}
15691569
1570- test peekStructReference {
1570+ test peekStructPointer {
15711571 var r : Reader = .fixed (&.{ 0x12 , 0x00 , 0x34 , 0x56 });
15721572 const S = extern struct { a : u8 , b : u16 };
15731573 switch (native_endian ) {
15741574 .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 )).* );
15771577 },
15781578 .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 )).* );
15811581 },
15821582 }
15831583}
0 commit comments