rust/tests/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
390 B
Rust
Raw Normal View History

2021-10-18 02:41:18 -05:00
// build-pass
trait Foo {}
struct Bar {
bytes: &'static [u8],
func: fn(&Box<dyn Foo>),
}
fn example(_: &Box<dyn Foo>) {}
const BARS: &[Bar] = &[
Bar {
bytes: "0".as_bytes(),
func: example,
},
Bar {
bytes: "0".as_bytes(),
func: example,
},
];
fn main() {
let x = todo!();
for bar in BARS {
(bar.func)(&x);
}
}