Skip to content

CStr::from_ptr documentation should mention that the C string's data must not change #48401

New issue

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

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

Already on GitHub? # to your account

Closed
jimblandy opened this issue Feb 21, 2018 · 1 comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@jimblandy
Copy link
Contributor

Callers of std::ffi::CStr::from_ptr are responsible for ensuring that the bytes pointed to by ptr, up through the terminating null byte, do not change during the lifetime of the returned &CStr. This is arguably implicit in the fact that the return value is a shared reference, but it seems to me it would be helpful to spell it out, along with the other stipulations already listed in from_ptr's documentation.

@sfackler sfackler added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Feb 21, 2018
@GuillaumeGomez
Copy link
Member

Good suggestion! I'm adding it.

@kennytm kennytm added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Feb 24, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Mar 6, 2018
kennytm added a commit to kennytm/rust that referenced this issue Mar 6, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants