Skip to content

Add conversions for &CStr and CString. #5326

@davidhewitt

Description

@davidhewitt

I just noticed that we don't have conversions for std::ffi::CStr or std::ffi::CString.

I think these should be totally possible and work very similarly to the existing conversions for &str / String.

PyUnicode_AsUTF8AndSize guarantees that there is a trailing NUL at the end (after the size bytes of text data). However due to the fact that there may be interior NUL bytes, we would probably need to use CStr::from_bytes_with_nul and fail the conversion if any interior nuls.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions