Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Make trait functions immutable #11

Closed
wants to merge 3 commits into from

Conversation

Wodann
Copy link

@Wodann Wodann commented Nov 27, 2019

This allows the traits to be implemented on immutable references, which is necessary whenever we have non-static instance of an allocator. Internal mutability can still be achieved through Cell or RefCell.

I wrote a bump allocator that requires this change.

This allows the traits to be implemented on immutable references.
Internal mutability can still be achieved through Cell or RefCell
@Wodann Wodann mentioned this pull request Nov 27, 2019
6 tasks
@Wodann
Copy link
Author

Wodann commented Nov 27, 2019

I fixed the formatting. If you are okay with the changes, I'll squash the two commits.

@Wodann Wodann force-pushed the feature/immutable-ref branch from f3c6909 to e639581 Compare November 27, 2019 22:04
@Wodann Wodann force-pushed the feature/immutable-ref branch from e639581 to bcc633e Compare November 27, 2019 22:06
@TimDiekmann
Copy link
Owner

Thanks for the pull request and sorry I haven't been able to comment yet.

I try to stick to &mut self as much as possible. While it would be possible to use internal mutability, I don't think it's a very clean approach.
I think the discussion in the Allocator RFC about this summarizes the advantages of &mut self well.

Let's wait and see how the discussion develops in rust-gamedev/wg#70.

@Wodann
Copy link
Author

Wodann commented Jan 19, 2020

Solved by issue #37.

@Wodann Wodann closed this Jan 19, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants