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

more no_std support #470

Closed
zendurix opened this issue Aug 20, 2020 · 10 comments · Fixed by #474
Closed

more no_std support #470

zendurix opened this issue Aug 20, 2020 · 10 comments · Fixed by #474

Comments

@zendurix
Copy link

Although itertools have no_std support it lacks implementations of most usfeful functions like collect_vec, sorted_by() etc in no_std mode. From my tests it seems that implementing it should be fairly easy, and I will try to contribute with solution.

@jswrenn
Copy link
Member

jswrenn commented Aug 20, 2020

What do you have in mind? Vec is not available in #[no_std] contexts.

@zendurix
Copy link
Author

So add alloc as dependency while in no_std. Most programs that use no_std already use alloc

@zendurix
Copy link
Author

This will require adding new feature no_std so alloc can be included only there, and change
#[cfg(not(feature = "use_std"))] to #[cfg(feature = "no_std")]

@jacobrosenthal
Copy link

jacobrosenthal commented Aug 20, 2020 via email

@zendurix
Copy link
Author

Still I think alloc is most reasonable option here, however I am still a beginner so I don't know other good options.

@jswrenn
Copy link
Member

jswrenn commented Aug 20, 2020

This will require adding new feature no_std so alloc can be included only there, and change
#[cfg(not(feature = "use_std"))] to #[cfg(feature = "no_std")]

That doesn't sound quite right to me. Crate features should add functionality, not remove it.

A better approach would be to add a use_alloc feature and change this line to:

use_std = ["use_alloc"]

...and to change this line to:

default = ["use_alloc"]

(I don't think we currently use any std-only features, so this won't be a breaking change.)

@zendurix Are you actually programming in an environment that has alloc but not std?

@zendurix
Copy link
Author

zendurix commented Aug 20, 2020

I am working on adding no_std feature to project, and I am already using alloc there. I think tomorrow (at my time) I will try to add and test this feature and if it works fine I will make PR.
use_alloc feature sounds good, even nalgebra has feature alloc and propably many more

@zendurix
Copy link
Author

I think default should stay like this:
default = ["use_std"]
And I don't see reason to use alloc in std.
I think best option (most crates do this like this) is to use std as default and alloc as optional feature.

@zendurix
Copy link
Author

I have made functional PR but I have accidentally used cargo fmt (because of good habbit :p). And I saw that you have this disabled. Should I restore code to previous formatting? (It have to be manual work though :/)

@zendurix
Copy link
Author

I have uploaded PR
#471

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.

3 participants