{{ code }} => {
let msg = if custom_ptr.is_null() {
String::new()
} else {
// SAFETY: caller guarantees custom_ptr is readable for custom_len bytes.
let bytes = unsafe { std::slice::from_raw_parts(custom_ptr.cast::<u8>(), custom_len) };
let value = String::from_utf8_lossy(bytes).into_owned();
if let Some(free) = free_string {
// SAFETY: free is the allocator-matched destructor supplied with the callback table.
unsafe { free(custom_ptr) };
}
value
};
VisitorResult::{{ variant_name }}(msg)
},