Modelled in C++
#include <cstddef>
#include <cstring>
class SelfReferentialBuffer {
std::byte data[1024];
std::byte* cursor = data;
public:
SelfReferentialBuffer(SelfReferentialBuffer&& other)
: cursor{data + (other.cursor - other.data)}
{
std::memcpy(data, other.data, 1024);
}
};
Investigate on Compiler Explorer
The SelfReferentialBuffer contains two members, data is a kilobyte of memory
and cursor is a pointer into the former.
Its move constructor ensures that cursor is updated to the new memory address.
This type can’t be expressed easily in Rust.