2020-10-20 12:40:02 -03:00
|
|
|
// run-pass
|
2019-04-17 00:11:19 +03:00
|
|
|
|
2020-05-23 16:26:20 -03:00
|
|
|
#![feature(unsized_fn_params)]
|
2019-04-17 00:11:19 +03:00
|
|
|
|
|
|
|
use std::ops;
|
2020-10-20 12:40:02 -03:00
|
|
|
use std::ops::Index;
|
2019-04-17 00:11:19 +03:00
|
|
|
|
|
|
|
pub struct A;
|
|
|
|
|
|
|
|
impl ops::Index<str> for A {
|
|
|
|
type Output = ();
|
2020-10-16 17:46:59 -03:00
|
|
|
fn index(&self, _: str) -> &Self::Output {
|
2020-10-20 12:40:02 -03:00
|
|
|
&()
|
2020-10-16 17:46:59 -03:00
|
|
|
}
|
2019-04-17 00:11:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ops::IndexMut<str> for A {
|
2020-10-16 17:46:59 -03:00
|
|
|
fn index_mut(&mut self, _: str) -> &mut Self::Output {
|
|
|
|
panic!()
|
|
|
|
}
|
2019-04-17 00:11:19 +03:00
|
|
|
}
|
|
|
|
|
2020-10-20 12:40:02 -03:00
|
|
|
fn main() {
|
|
|
|
let a = A {};
|
|
|
|
let s = String::new().into_boxed_str();
|
|
|
|
assert_eq!(&(), a.index(*s));
|
|
|
|
}
|