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

Make this crate no_std #17

Open
notgull opened this issue Oct 29, 2022 · 3 comments
Open

Make this crate no_std #17

notgull opened this issue Oct 29, 2022 · 3 comments

Comments

@notgull
Copy link

notgull commented Oct 29, 2022

This crate currently relies on libstd; however, I'd like to use this in a no_std program. Looking through the source code, it looks like the only std-exclusive import this uses (without additional features) is Error. If we made this optional, this crate could be used in no_std environments. This would be a breaking change.

In addition, it may also be a good idea to also eliminate the dependency on liballoc. Right now String is used in Key, but it may be replaced by an &'a str in order to allow usage on platforms without allocators and eliminate a potential allocation from the crate.

I will implement this PR if the behavior is desired.

@pyfisch
Copy link
Owner

pyfisch commented Oct 30, 2022

If we made this optional, this crate could be used in no_std environments.

This crate is primarily used by servo and high-level GUI tool-kits. Both depend on the standard library. What is your use-case for this crate in a no_std environment?

In addition, it may also be a good idea to also eliminate the dependency on liballoc. Right now String is used in Key, but it may be replaced by an &'a str in order to allow usage on platforms without allocators and eliminate a potential allocation from the crate.

Wouldn't make that the crate more complicated to use in general? I'm not convinced that the allocation has a measurable performance impact.

@notgull
Copy link
Author

notgull commented Oct 30, 2022

What is your use-case for this crate in a no_std environment?

I'm creating an experimental lightweight no_std toolkit, where the library is welded directly to winuser or libxcb without the standard library being involved.

@pyfisch
Copy link
Owner

pyfisch commented Oct 30, 2022

What is your use-case for this crate in a no_std environment?

I'm creating an experimental lightweight no_std toolkit, where the library is welded directly to winuser or libxcb without the standard library being involved.

Ok. I personally don't think that GUI applications gain much from avoiding the standard library. When your toolkit reaches the point where its used in applications I will reevaluate if keyboard-types should support operation without std. Then I might merge your patch.

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 a pull request may close this issue.

2 participants