Closed
Description
It seems that in Rust ~Trait are Const but that seems wrong, because the implementation of Trait can contain non-Const structs, such as those annotated "mutable", like RcMut.
This seems allows to create an RcMut pointing to itself, like this.
extern mod std;
use std::rc::*;
trait Foo
{
fn set(&mut self, v: RcMut<A>);
}
struct B
{
v: Option<RcMut<A>>
}
impl Foo for B
{
fn set(&mut self, v: RcMut<A>)
{
self.v = Some(v);
}
}
struct A
{
v: ~Foo,
}
fn main()
{
let a = A {v: ~B{v: None} as ~Foo};
let v = rc_mut_from_const(a);
let w = v.clone();
v.with_mut_borrow(|p| {p.v.set(w.clone());})
}
Metadata
Metadata
Assignees
Labels
No labels