alef 0.83.2

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
	jsonBytes{{ c_name }}, err := json.Marshal({{ go_param }})
	if err != nil {
		{{ err_action }}
	}
{% if empty_literal %}
	// A nil Go slice or map marshals to "null", while a non-nil empty one marshals to
	// "{{ empty_literal }}" — the form serde_json writes for an empty Rust collection, and the only
	// one the FFI's from_str accepts. Normalise so both spellings of "empty" cross the ABI
	// identically.
	if string(jsonBytes{{ c_name }}) == "null" {
		jsonBytes{{ c_name }} = []byte("{{ empty_literal }}")
	}
{% endif %}
	{{ c_name }} := C.CString(string(jsonBytes{{ c_name }}))
	defer C.free(unsafe.Pointer({{ c_name }}))