在C++中(如果错误,请纠正我),通过常量引用的临时绑定应该超过它所绑定的表达式。我认为Rust也是如此,但在两种不同的情况下,我得到了两种不同的行为。 考虑: struct A;
impl Drop for A { fn drop(&mut self) { println!("Drop A.") } }
struct B(*const A);
impl Drop for B { fn d
我正在用指针实现方式在不可变对象上实现装饰器模式。基本上我的设置是这样的 struct Object : ObjectBase {
void doSmth() override {
impl->doSmth();
}
// this is the function I'd like to implement
Object decorateWith