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

I'm not sure why it's different here #321

Closed
Cupnfish opened this issue Aug 24, 2020 · 1 comment · Fixed by #323
Closed

I'm not sure why it's different here #321

Cupnfish opened this issue Aug 24, 2020 · 1 comment · Fixed by #323
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change

Comments

@Cupnfish
Copy link
Contributor

pub fn get_mut(&mut self, handle: &Handle<T>) -> Option<&mut T> {
        self.events.send(AssetEvent::Modified { handle: *handle });
        self.assets.get_mut(&handle)
    }
    pub fn get_id_mut(&mut self, id: HandleId) -> Option<&mut T> {
        self.assets.get_mut(&Handle::from_id(id))
    }

I'm working on Bevy's code,Then I found this place here, I think it should be rewritten like this

    pub fn get_id_mut(&mut self, id: HandleId) -> Option<&mut T> {
        self.get_mut(&Handle::from_id(id))
    }
@Moxinilian Moxinilian added A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change labels Aug 24, 2020
@DJMcNab
Copy link
Member

DJMcNab commented Aug 24, 2020

Canonical links:

pub fn get_mut(&mut self, handle: &Handle<T>) -> Option<&mut T> {
self.events.send(AssetEvent::Modified { handle: *handle });
self.assets.get_mut(&handle)
}

pub fn get_id_mut(&mut self, id: HandleId) -> Option<&mut T> {
self.assets.get_mut(&Handle::from_id(id))
}

And I think I agree it should be changed to call the former.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants