Closed
Description
use std::ops::Index;
fn bar() {}
static UNIT: () = ();
struct S;
impl Index<fn()> for S {
type Output = ();
fn index(&self, f: fn()) -> &() { f(); &UNIT }
}
fn main() {
*S.index(bar);
// S[bar];
// ^^^^^^ expected fn pointer, found fn item
}
The docs for Index
(https://doc.rust-lang.org/std/ops/trait.Index.html) say:
container[index]
is actually syntactic sugar for*container.index(index)
but the error above indicates that this isn't true.
Metadata
Metadata
Assignees
Labels
No labels