Skip to content

Add a warning to CStr::as_ptr #29680

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 0 commits into from
Closed

Add a warning to CStr::as_ptr #29680

wants to merge 0 commits into from

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented Nov 7, 2015

@bluss was saying that this is a really common problem for people to run into on IRC. Hopefully this helps?

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@retep998
Copy link
Member

retep998 commented Nov 7, 2015

I agree that this is a common problem and some sort of documentation needs to be provided warning people about it.

@Gankra
Copy link
Contributor Author

Gankra commented Nov 7, 2015

bluss noted on IRC that providing more positive/affirmitive/specific advice might be better here. As in, "Make sure the returned pointer is only used while the original CString is live". Inclined to agree, but interested in discussing the best way to handle this sort of thing.

See #27769 for some related discussion.

@alexcrichton
Copy link
Member

Yeah I would also expect the docs to nudge you in the right direction by talking about having the original CString outlive the pointer itself

@steveklabnik
Copy link
Member

Yeah, there should be something here. We can nitpick it a bunch, or we can just merge this, and as I go through the API docs, I can clean it up later, either is fine for now imho. (I know you're busy, @gankro )

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.

5 participants