How do I use the Rust memory allocator for a C library that can be provided an allocator?
<p>I'm writing Rust bindings to a C library which has the option to use a third-party memory allocator. Its interface looks like this:</p>

<pre><code>struct allocator {
    void*(*alloc)(void *old, uint);
    void(*free)(void*);
};
</code></pre>

<p>The corresponding Rust struct is, I guess, the following:</p>

<pre><code>#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Allocator {
    alloc: Option&lt;extern "C" fn(*mut c_void, c_uint) -&gt; *mut c_void&gt;,
    free: Option&lt;extern "C" fn(*mut c_void)&gt;,
}
</code></pre>

<p>How can I implement these two extern functions that should mimic the allocator? I did not find anything really looking like the allocator API in Rust (I understand why however), so I'm curious if it is possible.</p>