Skip to content
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

feat: add CxxString::as_c_str() -> &CStr #1431

Merged
merged 1 commit into from
Feb 5, 2025
Merged

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Feb 5, 2025

Create &CStr from a CxxString instance by using std::string::c_str(), available since 1.64

The goal here is to add a helper method to CxxString, not to allow the new FFI type (hopefully some day...)

Note that the test cannot use C-string literal c"2020" because it is only available in 1.77+

Exposes `std::string::c_str()` call as a `as_c_str -> &CStr` wrapper, available since 1.64
Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit b3aa79f into dtolnay:master Feb 5, 2025
17 checks passed
@nyurik nyurik deleted the as_c_str branch February 5, 2025 21:25
@dtolnay
Copy link
Owner

dtolnay commented Feb 5, 2025

Published in 1.0.138.

@nyurik
Copy link
Contributor Author

nyurik commented Feb 5, 2025

thanks for such a quick turnaround @dtolnay !

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.

2 participants