Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Shorter keyword than target #12

Closed
Boscop opened this issue Oct 9, 2019 · 1 comment · Fixed by #13
Closed

Suggestion: Shorter keyword than target #12

Boscop opened this issue Oct 9, 2019 · 1 comment · Fixed by #13

Comments

@Boscop
Copy link
Collaborator

Boscop commented Oct 9, 2019

target is quite long to type, and it becomes noticeable when using the delegate macro a lot.
Could we shorten it for the next version of this crate? :)
E.g. how about using to as keyword, it also reads nicely, like "delegate to self.foo":

impl<S: Selectable> Switcher2<S> {
    delegate! {
        to self.switcher {
            pub fn page(&self) -> S;

            pub fn set_col(&mut self, col: Col);

            pub fn set_selected_brightness(&mut self, b: f32);
        }
    }
}

If you don't like to, how about for? It reads less like an English sentence compared to to, but has the benefit of getting syntax-highlighted in editors, and looks nice/familiar because it opens a block:

impl<S: Selectable> Switcher2<S> {
    delegate! {
        for self.switcher {
            pub fn page(&self) -> S;

            pub fn set_col(&mut self, col: Col);

            pub fn set_selected_brightness(&mut self, b: f32);
        }
    }
}

(Another possibility would be as but that already has a semantic connotation that could confuse readers in this context.)

@Kobzol
Copy link
Owner

Kobzol commented Oct 9, 2019

to sounds really nice! Delegate to self.field seems like a very elegant sentence to read, good idea!.

for and as seem a bit weird to me in this place. Another one that comes to mind is with, but to seems better to me.

#13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants