objc2 icon indicating copy to clipboard operation
objc2 copied to clipboard

Unstable: `&'static str` from Encoding

Open madsmtm opened this issue 2 years ago • 1 comments

Idea is that we generate an array in a const fn, and then get a reference to that array and put it in a const.

Requires https://github.com/rust-lang/rust/issues/76560.

Another approach would be to require Encode implementors to add a macro to the end, like this:

unsafe impl Encode for MyType {
    const ENCODING: Encoding<'static> = ...;
    end_encode_impl!();
}

madsmtm avatar Nov 03 '21 12:11 madsmtm

Though of course https://github.com/rust-lang/const-eval/issues/20 would make this much, much easier!

madsmtm avatar Nov 03 '21 12:11 madsmtm