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

Make extensions names constant #238

Closed
nyovaya opened this issue Sep 30, 2019 · 10 comments
Closed

Make extensions names constant #238

nyovaya opened this issue Sep 30, 2019 · 10 comments

Comments

@nyovaya
Copy link

nyovaya commented Sep 30, 2019

The 'name' functions from e.g. "ash::extensions::khr::Surface" and other extensions should be const.

@Ralith
Copy link
Collaborator

Ralith commented Oct 1, 2019

This is not currently possible, as CStr::from_bytes_with_nul_unchecked is not const in stable rust.

@Friz64
Copy link
Contributor

Friz64 commented Jan 19, 2020

This is not currently possible, as CStr::from_bytes_with_nul_unchecked is not const in stable rust.

It is now.

@MaikKlein
Copy link
Member

Oh nice, I've totally missed that. I'll fix it after I am done refactoring the generator.

@Friz64
Copy link
Contributor

Friz64 commented Jan 19, 2020

Additionally, this issue is pretty much the same as #79.

@MaikKlein
Copy link
Member

Yeah closing this in favor of #79

@Ralith
Copy link
Collaborator

Ralith commented Jan 19, 2020

It is now.

It is not. The nightly feature in question is const_cstr_unchecked. rustdoc displays the const qualifier erroneously.

@Friz64
Copy link
Contributor

Friz64 commented Jan 19, 2020

Oh wow, i didn't know that rustdoc is not to trust sometimes.

@Friz64
Copy link
Contributor

Friz64 commented Jan 19, 2020

I guess we can still make it happen by copying the implementation of from_bytes_with_nul_unchecked.

pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr {
    &*(bytes as *const [u8] as *const CStr)
}

@Ralith
Copy link
Collaborator

Ralith commented Jan 19, 2020

If it were that simple it would already be stable:

error[E0658]: dereferencing raw pointers in constant functions is unstable

@Friz64
Copy link
Contributor

Friz64 commented Jan 19, 2020

Oh, i thought it was some weird thing where a perfectly working function is still not stable.

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