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

Could from_slice_unchecked be made const for the string types? #474

Closed
ModProg opened this issue Jul 6, 2024 · 0 comments · Fixed by #475
Closed

Could from_slice_unchecked be made const for the string types? #474

ModProg opened this issue Jul 6, 2024 · 0 comments · Fixed by #475

Comments

@ModProg
Copy link
Contributor

ModProg commented Jul 6, 2024

This would allow putting them in constants.

The only issue I foresee would be the plan to eventually move away from zero terminated strings, as mentioned here:

/// View this struct as a CStr.
///
/// Note: As of dbus 0.9, this is made private to be able to make it easier for a potential
/// native implementation using "str" instead of "cstr".
pub (crate) fn as_cstr(&self) -> &CStr {
unsafe {
CStr::from_bytes_with_nul_unchecked(self.0.as_bytes())
}
}

Code change required for this would only be a single line, so this is more about the question of whether this should be implemented. As I'd be happy to contribute the needed PR.

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 a pull request may close this issue.

1 participant