Description
There has been some interest in putting out a version of regex that doesn't depend on std itself, but instead depends just on alloc. This is within reach because regex already doesn't rely too much on platform specific details, and mostly just depends on dynamic memory allocation. There are however some parts of the regex API that will need to be tweaked. For example, regex uses std::io::Error
, which isn't available in alloc
. This is why regex 1.0 got a use_std
/std
feature. Namely, compiling regex without that feature fails today. This will allow us to change the semantics of that compilation mode without breaking backwards compatibility.
@ZackPierce has been diligently adding support for this by starting with regex's dependencies. So far:
- Add no_std + alloc support by way of a default "std" feature flag BurntSushi/utf8-ranges#8
- Add experimental feature flagged no_std support BurntSushi/aho-corasick#28
- Add no_std + alloc support for ucd-util BurntSushi/ucd-generate#1
I thought it would be good to track this issue at a higher level so we can discuss a game plan. I'd also like to share some of my thoughts/constraints on the process.
I basically think that we should do this. What I am unsure of is the timeline. For the most part, my own personal maintenance bandwidth is very limited, and to this end, I've generally avoided nightly-only support of things. (I've made some exceptions. Support for things like Pattern
happened before I knew better, and support for SIMD happened because I am very excited about it and got involved with the SIMD stabilization effort.) Namely, I cannot and will not be beholden to nightly breakages because I simply can't keep up. To that end, I would like to know more about what the plan is for no_std
environments. Is the alloc
crate setup generally where we think we're going? If so, and if it remains relatively stable, I think I could get on board with this relatively soon.
It's also worth saying that some changes are simpler than others. For example, making utf8-ranges
compatible with no_std
is pretty reasonable, but the aho-corasick
changes are quite a bit broader. I have concerns over peppering conditional compilation everywhere, and I think those sorts of things are very hard to maintain. I'm hopeful we can find a better way. This gets worse when the public API is impacted. The complexity and maintenance burden goes way up. This is apparently so bad that it was worth adding a new dependency (cfg-if
) that must be paid for by everyone just to support the no_std
users. I'm not especially excited about that, particularly if the trend continues.
For the most part, I really wasn't intending on tackling this feature until more stuff stabilized. But I wanted to get my thoughts out there so that there are no surprises.
I welcome other thoughts on the matter!