Skip to content

add efficient conversion from CString #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

add efficient conversion from CString #23

wants to merge 1 commit into from

Conversation

aplavin
Copy link

@aplavin aplavin commented Aug 1, 2023

UnsafeArrays just provides a DenseArray wrapper around a pointer and length. Hope that adding this dep is fine!
In return, it gives almost zero-cost conversion from CString.

@aplavin
Copy link
Author

aplavin commented Aug 16, 2023

bump!

@stevengj
Copy link
Member

No, this is too unsafe. If the caller wants an unsafe array, they can use one themselves, but we can’t assume a CString pointer will remain valid after the call returns.

@stevengj stevengj closed this Aug 16, 2023
@aplavin
Copy link
Author

aplavin commented Aug 17, 2023

That's unfortunate - users who need zero-cost conversion from C strings have to implement it manually every time

@stevengj
Copy link
Member

If we wanted this, it would have to be a method of unsafe_wrap, not a constructor, since the semantics you are looking for mirror those of unsafe_wrap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants