Closed
Description
// We need a mutable borrow to an empty struct because it implements a trait
// that takes &mut self.
struct Empty;
impl Iterator<int> for Empty {
fn next(&mut self) -> Option<int> { None }
}
fn do_something_with(a : &mut Iterator<int>) {
println!("{}", a.next())
}
fn main() {
// This is OK...
let mut a = Empty;
do_something_with(&mut a);
// But if I want to use an immediate expression, as is possible with
// non-empty structs...
// "error: cannot borrow immutable static item as mutable"
do_something_with(&mut Empty);
}
It seems like it would make sense to allow mutably borrowing the Empty singleton.