Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Throwaway self ref without custom receiver
I want to be able to have a method with a throwaway self reference. Is there a way to do the following:
struct Foo;
impl Foo {
fn throwaway_self_ref(&_self) {}
}
This one doesn't work; it wants a type after self
and doesn't like the &
.
This one compiles but the method becomes an associated function, and can't be called with dot notation:
impl Foo {
fn throwaway_self_ref(_self: &Self) {}
fn bar(&self) {
// fails
self.throwaway_self_ref();
}
}
Is there a way to do this? Would it make sense to make an exception for the self
behavior for _self
? Is that something that would get introduced at an edition boundary?
1 post - 1 participant
🏷️ rust_feed