3 ms·
For example: "The motivation for this design philosophy is to enable users to write any manner of custom allocator strategy they find necessary, instead of forc
by ngrilly 9y ago
For example: "The motivation for this design philosophy is to enable users to write any manner of custom allocator strategy they find necessary, instead of forcing them or even encouraging them into a particular strategy that may not suitable for their needs. For example, Rust seems to encourage a single global allocator strategy, which is not suitable for many usecases such as OS development and high-performance game development."
- steveklabnik 9y agoNB: that is sorta true right now (as the sentence says, "seems to"), but it's also an area of active work; we don't expect Rust to end up that way. To elaborate a bit: Right now, the standard library relies on an allocator. The language itself does not. If you want to write your own types and back them up by your own allocator, you can 100% do that today. But that doesn't help you with any of the stuff in the stdlib. We have work on: 1. A trait for allocation, so that allocators can have the same APIs. https://github.com/rust-lang/rust/issues/32838 https://github.com/rust-lang/rust/issues/32838 2. Swapping out that allocator entirely, wholesale. Tor and Firefox both want this. https://github.com/rust-lang/rust/issues/27389 https://github.com/rust-lang/rust/issues/27389 3. Allowing you to swap out the allocator of stdlib types on a per-instance basis; this almost had an RFC for the needed machinery, but was postponed. Will probably come up again in the coming year after #1 & #2 get resolved.
- ngrilly 9y agoDuly noted ;-)