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

Change component definitions to use Self and destruct system data tuple in parameter list. #206

Merged
merged 1 commit into from
Jun 26, 2017

Conversation

WaDelma
Copy link
Member

@WaDelma WaDelma commented Jun 25, 2017

This PR changes component definitions from:

impl Component for MyTotallyRadComponent {
    type Storage = VecStorage<MyTotallyRadComponent>;
}

to

impl Component for MyTotallyRadComponent {
    type Storage = VecStorage<Self>;
}

which is shorter for long types and easier to rename. Benefits are especially great when the type has to be repeated multiple times (eg. FlaggedStorage<MyTotallyRadComponent, VecStorage<MyTotallyRadComponent>> vs FlaggedStorage<Self, VecStorage<Self>>)

It also moves system data destructuring for tuples:

fn run(&mut self, data: Self::SystemData) {
    let (first_component, mut second_component) = data;

to

fn run(&mut self, (first_component, mut second_component): Self::SystemData) {

which is shorter and conveys the fact that these component storages are takes as parameter (same way as tuple desugaring takes parameters).

NOTE: Removal of spaces at end of lines was done automatically by editor

@kvark
Copy link
Member

kvark commented Jun 26, 2017

Thanks, looks great!
bors r+

bors bot added a commit that referenced this pull request Jun 26, 2017
206: Change component definitions to use Self and destruct system data tuple in parameter list. r=kvark

This PR changes component definitions from:
````rust
impl Component for MyTotallyRadComponent {
    type Storage = VecStorage<MyTotallyRadComponent>;
}
````
to
````rust
impl Component for MyTotallyRadComponent {
    type Storage = VecStorage<Self>;
}
````
which is shorter for long types and easier to rename. Benefits are especially great when the type has to be repeated multiple times (eg. `FlaggedStorage<MyTotallyRadComponent, VecStorage<MyTotallyRadComponent>>` vs `FlaggedStorage<Self, VecStorage<Self>>`)

It also moves system data destructuring for tuples:
````rust
fn run(&mut self, data: Self::SystemData) {
    let (first_component, mut second_component) = data;
````
to
````rust
fn run(&mut self, (first_component, mut second_component): Self::SystemData) {
````
which is shorter and conveys the fact that these component storages are takes as parameter (same way as tuple desugaring takes parameters).

NOTE: Removal of spaces at end of lines was done automatically by editor
@bors
Copy link
Contributor

bors bot commented Jun 26, 2017

Build succeeded

@bors bors bot merged commit dc3cc61 into amethyst:master Jun 26, 2017
xMAC94x pushed a commit to xMAC94x/specs that referenced this pull request Mar 10, 2021
206: Update crate versions to `0.11.0` and `0.6.3`. r=azriel91 a=azriel91

Release changes for `0.11.0`.

Co-authored-by: Azriel Hoh <azriel91@gmail.com>
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 this pull request may close these issues.

2 participants