Skip to content

Commit ded0bca

Browse files
author
Michael Ward
committed
[Rust] codegen now implements: "From<&'a mut WriteBuf<'a>> for &'a mut [u8]"
1 parent 633fe63 commit ded0bca

File tree

1 file changed

+7
-0
lines changed
  • sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/rust

1 file changed

+7
-0
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/rust/LibRsDef.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@ static void generateWriteBuf(final Writer writer, final ByteOrder byteOrder) thr
277277
indent(writer, 2, "len\n");
278278
indent(writer, 1, "}\n");
279279

280+
indent(writer, 0, "}\n");
281+
282+
indent(writer, 0, "impl<%s> From<&%1$s mut %2$s<%1$s>> for &%1$s mut [u8] {\n", BUF_LIFETIME, WRITE_BUF_TYPE);
283+
indent(writer, 1, "#[inline]\n");
284+
indent(writer, 1, "fn from(buf: &%s mut %2$s<%1$s>) -> &%1$s mut [u8] {\n", BUF_LIFETIME, WRITE_BUF_TYPE);
285+
indent(writer, 2, "buf.data\n");
286+
indent(writer, 1, "}\n");
280287
indent(writer, 0, "}\n\n");
281288
}
282289
}

0 commit comments

Comments
 (0)