2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2014-03-12 19:54:43 +04:00
|
|
|
// Tests that unary structs can be mutably borrowed.
|
|
|
|
|
|
|
|
struct Empty;
|
|
|
|
|
2014-10-01 19:31:21 +13:00
|
|
|
trait T<U> {
|
|
|
|
fn next(&mut self) -> Option<U>;
|
|
|
|
}
|
2015-03-25 17:06:52 -07:00
|
|
|
impl T<isize> for Empty {
|
|
|
|
fn next(&mut self) -> Option<isize> { None }
|
2014-03-12 19:54:43 +04:00
|
|
|
}
|
|
|
|
|
2019-05-28 14:47:21 -04:00
|
|
|
fn do_something_with(a : &mut dyn T<isize>) {
|
2014-12-20 00:09:35 -08:00
|
|
|
println!("{:?}", a.next())
|
2014-03-12 19:54:43 +04:00
|
|
|
}
|
|
|
|
|
2014-03-12 10:31:52 -07:00
|
|
|
pub fn main() {
|
2014-03-12 19:54:43 +04:00
|
|
|
do_something_with(&mut Empty);
|
2014-03-12 10:31:52 -07:00
|
|
|
}
|