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

Design a procedural macro (#[derive(Keyed)]) for generatively enabling a structure to be indexed by its keys #61

Open
Tracked by #73
FL03 opened this issue Apr 4, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request macro Any additions or improvements to procedural macros rust Improvements or additions that update the Rust code
Milestone

Comments

@FL03
Copy link
Member

FL03 commented Apr 4, 2024

Example

use scsys::Keyed;

#[derive(Debug, Keyed)]
#[scsys(key = S)]
pub struct Sample {
    a: usize,
    b: usize
}

fn main() {
    let sample = Sample { a: 10, b: 100 };
    assert_eq!(sample[S::A], &10);
}
@FL03 FL03 added enhancement New feature or request rust Improvements or additions that update the Rust code labels Apr 4, 2024
@FL03 FL03 self-assigned this Apr 4, 2024
@FL03 FL03 added this to the v0.2.1 milestone Apr 10, 2024
@FL03 FL03 added the macro Any additions or improvements to procedural macros label Apr 10, 2024
@FL03 FL03 changed the title Feature: create a keyed trait that allows for any structure to be indexed by a set of keys Keyed: a derive macro for indexing a structure by its keys Apr 10, 2024
@FL03 FL03 modified the milestones: v0.2.1, v0.2.2 Apr 28, 2024
@FL03 FL03 linked a pull request Apr 28, 2024 that will close this issue
1 task
@FL03 FL03 closed this as completed in #67 May 11, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to 👀 In review in @scsys/team:roadmap May 11, 2024
@FL03 FL03 reopened this May 17, 2024
@github-project-automation github-project-automation bot moved this from 👀 In review to 📋 Backlog in @scsys/team:roadmap May 17, 2024
@FL03 FL03 modified the milestones: v0.2.2, v0.2.3 May 17, 2024
@FL03 FL03 removed a link to a pull request May 17, 2024
1 task
@FL03 FL03 linked a pull request May 17, 2024 that will close this issue
@FL03 FL03 changed the title Keyed: a derive macro for indexing a structure by its keys Design a procedural macro (#[derive(Keyed)]) for generatively enabling a structure to be indexed by its keys May 17, 2024
@FL03
Copy link
Member Author

FL03 commented May 17, 2024

One alternative consideration would to simply require stores to have public fields.

@FL03 FL03 removed a link to a pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request macro Any additions or improvements to procedural macros rust Improvements or additions that update the Rust code
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant