3 ms·
It's not going to be something considered idiomatic, especially in a library. Rust support quite a few things which you're not supposed to use other than in exc
by Manishearth 10y ago
It's not going to be something considered idiomatic, especially in a library. Rust support quite a few things which you're not supposed to use other than in exceptional circumstances (e.g. catching/recovering panics -- there has been no slippery slope yet).
Nor will the stdlib expose a GC API. I do intend on writing an example GC for this, but really each use case will probably need its own special GC implementation; since they are special use cases.
That's not a decision to take lightly.
I don't think GC will be something that can be silently pulled in, either, since you will need to change your codegen flags at the top level. This could be abstracted away by cargo, but it might be better if it wasn't; and you have to explicitly tell cargo in the toplevel toml file that you want GC to be on (and get a compile error if you try to compile without those flags).
==================
Also, the Rust community seems to be very careful about unnecessary costs. Even Rc<T> isn't used much, and when it is, it seems to be used at the application (not library) level.
When I have to box a closure or iterator in Rust because `-> impl Trait` doesn't exist (where you can return anonymous types by specifying the trait they implement), I feel so annoyed by the cost. As do many other Rustaceans. In reality, this is a pretty rare thing to do and the costs are negligible; but it feels annoying to not have the best performance. In such an environment, I doubt a library that frivolously uses GC will survive.