Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no_std support #165

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

no_std support #165

wants to merge 30 commits into from

Conversation

CrabNejonas
Copy link

@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