On 4/19/22 5:12 AM, Stanislav Blinov wrote:
On Tuesday, 19 April 2022 at 06:05:27 UTC, Ali Çehreli wrote:

One quirk of rawWrite and rawRead is that they want slices of objects. It is a little awkward when there is just one thing to write and read. Uncompiled but something like this:

  int i = 42;
  file.rawWrite(*cast((int[1]*)(&i)));  // Casted to be an array of 1

Yuck :)

```d
file.rawWrite((&i)[0..1]);
```

Hm... an "asStaticArray" or something similar would be useful for such things (and safe too):

```d
ref T[1] asStaticArray(T)(return ref T item) @trusted
{
   return *(cast(T[1])&item);
}
```

-Steve

Reply via email to