gir icon indicating copy to clipboard operation
gir copied to clipboard

`data` parameter for `gio::content_type_guess` should be an `Option`

Open euclio opened this issue 3 years ago • 3 comments

According to the documentation, NULL is a valid value for the data parameter of g_content_type_guess. However, the Rust bindings type it as &[u8], making it impossible to pass a null value.

euclio avatar May 09 '21 13:05 euclio

Seems like gir does not handle nullability annotations correctly in combination with arrays.

sdroege avatar May 09 '21 14:05 sdroege

Yep, I managed to track it down to this line. Not sure if it's safe to remove completely or if it needs to be smarter, though.

euclio avatar May 10 '21 22:05 euclio

It should almost work, but in addition you will also need to carry through the nullability in TransformationType::Length so that inside src/codegen/function_body_chunk.rs it does array.map(|array| array.len()).unwrap_or(0) instead of array.len().

Want to give it a try?

sdroege avatar May 11 '21 06:05 sdroege