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

Support no_std builds #10

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@mbrubeck
Copy link
Contributor

mbrubeck commented Jul 24, 2018

This adds two features, both enabled by default:

  • normalization - enables the canonical_caseless_match and
    compatibility_caseless_match methods, which require the
    unicode_normalization crate.

  • alloc - enables the default_case_fold_str convenience method,
    which requires allocating a String.

Disabling both these features allows use of this crate for case folding in
no_std programs.

@mbrubeck

This comment has been minimized.

Copy link
Contributor Author

mbrubeck commented Jul 24, 2018

r? @SimonSapin

Note: The alloc feature could eventually depend on liballoc instead of libstd, if that subset is stabilized.

@CAD97

This comment has been minimized.

Copy link

CAD97 commented Jul 24, 2018

I don't think you can cfg individual fn off of a trait where that trait is implementable outside of the current crate. cfgs are supposed to be purely additive, and a codependency activating one of these cfgs could break an unrelated crate that built without the feature.

@mbrubeck

This comment has been minimized.

Copy link
Contributor Author

mbrubeck commented Jul 24, 2018

I don't think you can cfg individual fn off of a trait where that trait is implementable outside of the current crate.

Hmm, good point. We could make the trait private when the feature is disabled, and only provide the top-level functions, or we could make a breaking change and split it into two traits.

@mbrubeck mbrubeck force-pushed the mbrubeck:no_std branch from 2ea9fed to 0213bf4 Jul 24, 2018

@mbrubeck

This comment has been minimized.

Copy link
Contributor Author

mbrubeck commented Jul 24, 2018

We could make the trait private when the feature is disabled, and only provide the top-level functions

I implemented this for now, as it is simple and backward-compatible.

This reduces the API for no_std crates to just default_caseless_match_str. We could expand on that in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.