You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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.
The text was updated successfully, but these errors were encountered:
It seems like it would make sense to allow mutably borrowing the Empty singleton.
The text was updated successfully, but these errors were encountered: