2024-02-16 14:02:50 -06:00
|
|
|
//@ run-pass
|
|
|
|
//@ check-run-results
|
2022-11-10 17:36:20 -06:00
|
|
|
|
|
|
|
#![feature(dyn_star)]
|
2022-11-23 20:36:46 -06:00
|
|
|
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
|
2022-11-10 17:36:20 -06:00
|
|
|
|
|
|
|
trait AddOne {
|
|
|
|
fn add1(&mut self) -> usize;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AddOne for usize {
|
|
|
|
fn add1(&mut self) -> usize {
|
|
|
|
*self += 1;
|
|
|
|
*self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_one(i: &mut (dyn* AddOne + '_)) -> usize {
|
|
|
|
i.add1()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = 42usize as dyn* AddOne;
|
|
|
|
|
|
|
|
println!("{}", add_one(&mut x));
|
|
|
|
println!("{}", add_one(&mut x));
|
|
|
|
}
|