Skip to content

Support no_std builds #10

New issue

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

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

Already on GitHub? # to your account

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

Support no_std builds #10

wants to merge 2 commits into from

Conversation

mbrubeck
Copy link
Contributor

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
Copy link
Contributor Author

r? @SimonSapin

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

@CAD97
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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants