Open
Description
The most common case for deep recursion is when handling deeply nested recursive types, where SomeType
has a Box<SomeType>
(or some other container) internally that can be nested really deeply, and then any standard operations that need to walk entire type, fail.
Suggestion: would it be worth providing a Stacker<T>
newtype that automatically handles Deref
, DerefMut
, PartialEq
, PartialOrd
, Hash
, Debug
and so on and all other standard traits, but automatically checks and grows the stack before recursing?
It seems that such type would magically handle most common cases without user having to write any stack-growing code.
Activity
RReverser commentedon Mar 24, 2020
If you think this is useful, but doesn't belong in this crate, that's also fine and I'm happy to implement and publish it as a separate crate, but thought it might be useful raising here first.
nagisa commentedon Mar 24, 2020
I think it would make a lot of sense inside this crate, even if it ends up being opinionated in terms of how things are implemented, as long as they are well documented.
RReverser commentedon Mar 25, 2020
Cool. I guess the only open question is how to choose default limits for
maybe_grow
... Is there any "safe" lowest boundary for red zone that we could use universally?Alternatively, if the callback is marked as
#[inline(never)]
, is the red zone more predictable than with potentially inlined callbacks?nagisa commentedon Mar 26, 2020
There's probably not a good red zone that would apply universally. Perhaps it would make sense to supply some value as a defaulted const generic (when those come around?).
RReverser commentedon Mar 26, 2020
I guess, although might take long time to wait for it.
nagisa commentedon Nov 14, 2021
There's some support for const generics now, so this is back on the table, I guess.