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 fine-grained feature gates for formatting methods #400

Closed
mzabaluev opened this issue Nov 25, 2021 · 3 comments
Closed

More fine-grained feature gates for formatting methods #400

mzabaluev opened this issue Nov 25, 2021 · 3 comments
Labels
A-formatting Area: formatting C-enhancement Category: an enhancement with existing code E-medium Some experience needed.

Comments

@mzabaluev
Copy link
Contributor

mzabaluev commented Nov 25, 2021

It would be good to get a subset of the formatting functionality available on no-std targets. On the surface, the format methods can be changed to return alloc::string::String without breaking the current API. Also, #375 discusses formatting into a &mut impl core::fmt::Write, which would require neither std nor alloc.

Consider the feasibility of introducing more fine-tuned formatting feature gates to decouple availability of these methods from the requirement of std:

[features]
formatting = ["formatting-alloc", "std", "itoa/std"]  # full API including format_into
formatting-alloc = ["formatting-core", "alloc"]  # for format
formatting-core = ["itoa"]  # for formatting into &mut fmt::Write
@jhpratt jhpratt added A-formatting Area: formatting C-enhancement Category: an enhancement with existing code E-medium Some experience needed. labels Nov 25, 2021
@mzabaluev
Copy link
Contributor Author

mzabaluev commented Nov 26, 2021

In a future backward-incompatible release, the formatting feature could be redesigned to be orthogonal to alloc/std and enable methods in combination with those:

  • #[cfg(all(feature = "formatting", feature = "alloc"))] would enable format;
  • #[cfg(all(feature = "formatting", feature = "std"))] would enable format_into;
  • #[cfg(feature = "formatting")] would only enable format_into_fmt.

@jhpratt
Copy link
Member

jhpratt commented Nov 26, 2021

The formatting feature currently relies on std, so that change by itself is not breaking. I haven't had time to look at this in further detail.

cc @CryZe as I know you looked into this a bit.

@jhpratt
Copy link
Member

jhpratt commented Mar 10, 2022

As this was predicated on support for fmt::Write, closing for the time being. It may be reopened if necessary once support for fmt::Write lands (there's no timeframe for this).

@jhpratt jhpratt closed this as completed Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-formatting Area: formatting C-enhancement Category: an enhancement with existing code E-medium Some experience needed.
Projects
None yet
Development

No branches or pull requests

2 participants