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