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

2 getter impl's for same field #85

Closed
tmillr opened this issue Jun 5, 2022 · 1 comment
Closed

2 getter impl's for same field #85

tmillr opened this issue Jun 5, 2022 · 1 comment

Comments

@tmillr
Copy link

tmillr commented Jun 5, 2022

#[derive(Getters, CopyGetters)]
#[getset(get)]
#[cfg_attr(debug_assertions, derive(Debug))]
pub struct Rank {
    #[getset(get_copy)]
    val: RankValue,
    desc: Desc,
}

emits...

    impl Rank {
        #[inline(always)]
        fn val(&self) -> &RankValue {
            &self.val
        }
        #[inline(always)]
        fn desc(&self) -> &Desc {
            &self.desc
        }
    }
    impl Rank {
        #[inline(always)]
        fn val(&self) -> RankValue {
            self.val
        }
    }

The intention is to have all fields get by ref except for val which should get by Copy (without having to revert to specifying at the field-level for all fields).

@Hoverbear
Copy link
Collaborator

I suggest not using struct level #[getset] attrs.

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

No branches or pull requests

2 participants