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

Beef can implement const Deref? #48

Open
uselessgoddess opened this issue Jul 24, 2022 · 5 comments
Open

Beef can implement const Deref? #48

uselessgoddess opened this issue Jul 24, 2022 · 5 comments

Comments

@uselessgoddess
Copy link

In the case of Beef::borrowed can be implemented const Deref. Will it be done?

@CAD97
Copy link

CAD97 commented Jul 24, 2022

impl const Trait is a long way from being stable, so this is probably a bit premature :)

@uselessgoddess
Copy link
Author

Yes, I understand. But unstable rust is my love. I will wait

@maciejhirsz
Copy link
Owner

We already have const_fn feature which requires nightly, so if we can put this behind a feature flag (same or a new one) I'd be happy to accept a PR.

@uselessgoddess
Copy link
Author

Check out my PR #49.
I believe it was possible to avoid code duplication.

@Caellian
Copy link

Caellian commented Nov 6, 2024

Any sort of access to underlying data is fine. I don't mind if it's incredibly convoluted, inconvenient and I have to wrap it in

std::str::from_utf8_unchecked(std::slice::from_raw_parts(cow.get_raw_ptr().as_ptr(), length))

I just need a const way to access the data, today, not in 5 or so years.

Currently can't even transmute the Cow into a pointer to access it in const context. I added this simple method in #56, as I don't want to use nightly over something as simple as this.

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

No branches or pull requests

4 participants