Skip to content

Commit 515c163

Browse files
committed
FEAT: conversion of struct! to binary!
1 parent 85097fc commit 515c163

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/core/t-string.c

+4
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ static REBSER *make_binary(REBVAL *arg, REBOOL make)
268268
ser->data[12] = 0;
269269
break;
270270

271+
case REB_STRUCT:
272+
ser = Copy_Series_Part(VAL_STRUCT_DATA_BIN(arg), VAL_STRUCT_OFFSET(arg), VAL_STRUCT_LEN(arg));
273+
break;
274+
271275
default:
272276
ser = 0;
273277
}

src/tests/units/struct-test.r3

+8
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ Rebol [
133133

134134
===end-group===
135135

136+
137+
===start-group=== "Struct conversion"
138+
--test-- "to binary! struct!"
139+
s: make struct! [a: [uint16!] 1 b: [int32!] -1]
140+
--assert #{0100FFFFFFFF} = to binary! s
141+
===end-group===
142+
143+
136144
===start-group=== "Invalid struct construction"
137145
--test-- "Missing struct init value"
138146
;@@ https://github.com/zsx/r3/issues/50

0 commit comments

Comments
 (0)