Skip to content

self as target doesn't seem to work #25

@Boscop

Description

@Boscop

I have a derived getter, using the getset crate, but I also need to impl a trait that has the same getter.
This works:

#[derive(Getters)]
pub struct Struct {
	member: Member,
	#[getset(get)]
	foo: Foo,
}

impl Trait for Struct {
	delegate! {
		to self.member {
			fn bar(&self) -> Bar;
		}
	}

	fn foo(&self) -> &Foo {
		self.foo()
	}
}

But this doesn't work:

impl Trait for Struct {
	delegate! {
		to self.member {
			fn bar(&self) -> Bar;
		}

		to self {
			fn foo(&self) -> &Foo;
		//  ^^ error: expected identifier or integer
		}
	}
}

But it should also work, because the handwritten delegation from trait to self.foo() works :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions