Skip to content

no_std support#165

Open
CrabNejonas wants to merge 30 commits into
BurntSushi:masterfrom
crabnebula-dev:master
Open

no_std support#165
CrabNejonas wants to merge 30 commits into
BurntSushi:masterfrom
crabnebula-dev:master

Conversation

@CrabNejonas
Copy link
Copy Markdown

@CrabNejonas CrabNejonas commented Nov 2, 2023

This PR adds two feature flags std and alloc (both of which are enabled by default) allowing this crate to be used in no_std contexts such as embedded (or wasm if you want to optimize the file size really aggressively like me).

This works because the basic fst query operations such as get and contains actually do not allocate at all and building the actual fst can be done in a build script in most situations.

std only really enables features that depend on io::Write while most of the fst functions (all construction and complex query types) are gated behind alloc

I made this change mostly for myself, but thought I might as well volunteer it for inclusion even though the macros and conditional includes do complicate the codebase a fair bit I think it's a neat addition.

Edit: Ah and full no_std mode needs nightly, bc of error in core, which shouldn't be a problem in practice since most no_std users are on nightly anyway, but I'm happy to rip that out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant