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

[tracking] fmt #247

Closed
21 of 22 tasks
dignifiedquire opened this issue Sep 27, 2019 · 3 comments · Fixed by #311
Closed
21 of 22 tasks

[tracking] fmt #247

dignifiedquire opened this issue Sep 27, 2019 · 3 comments · Fixed by #311
Labels
api design Open design questions
Milestone

Comments

@dignifiedquire
Copy link
Member

dignifiedquire commented Sep 27, 2019

When trying to implement io::Write::write_fmt, I ran into the issue that the implementation requires the use of a second Write trait, the one in fmt.

If we want to properly implement this, I believe an async version of that is required as well, which in turn triggers usages like implementing the write! macro in an async form.

Ref: #245 #131

Usage: https://github.com/rust-lang/rust/blob/master/src/libstd/io/mod.rs#L1412

Tracking List

Structs

  • Arguments (re-export)
  • DebugList (re-export)
  • DebugMap (re-export)
  • DebugSet (re-export)
  • DebugStruct (re-export)
  • DebugTuple (re-export)
  • Error (re-export)
  • Formatter (re-export)

Enums

  • Alignment (re-export)

Traits

  • Binary (re-export)
  • Debug (re-export)
  • Display (re-export)
  • LowerExp (re-export)
  • LowerHex (re-export)
  • Octal (re-export)
  • Pointer (re-export)
  • UpperExp (re-export)
  • UpperHex (re-export)
  • Write

Functions

  • fmt::format (re-export)
  • fmt::write

Type Defintions

  • Result (re-export)
@yoshuawuyts
Copy link
Contributor

@dignifiedquire as we've talked about in chat, I agree with the reasoning here and we should indeed create a new fmt submodule.

I'll update your initial comment to include a list of things to port, and label this as a tracking issue.

@yoshuawuyts yoshuawuyts changed the title Async version of fmt::Write [tracking] fmt Sep 27, 2019
@yoshuawuyts yoshuawuyts added this to the std parity milestone Sep 27, 2019
@yoshuawuyts yoshuawuyts added the api design Open design questions label Sep 27, 2019
bors bot added a commit that referenced this issue Sep 28, 2019
245: feat: missing Read and Write methods r=yoshuawuyts a=dignifiedquire

Ref: #131 

- [x] Read::by_ref
- [x] Read::bytes
- [x] Read::chain
- [x] Read::take
- [ ] Write::by_ref
- [ ] ~~Write::write_fmt~~ postponed until #247 is solved

Needs fixing:

- [x] `BufRead` for `Take`
- [x] `BufRead` for `Chain`
- [ ] `by_ref` conflict between `Read` and `Write`, unable to add both, as they conflict, and the current state of things does not allow to differentiate between the two.


Co-authored-by: dignifiedquire <[email protected]>
@ghost
Copy link

ghost commented Oct 2, 2019

I don't think we need an async version of std::fmt::Write because that trait is only implemented on String and Formatter, which are not async data structures.

The only part of fmt that could be asyncified, I think, is the std::fmt::write function. But it's not used that often in practice and we could just provide an async version of the write! macro instead.

@yoshuawuyts
Copy link
Contributor

The only part of fmt that could be asyncified, I think, is the std::fmt::write function. But it's not used that often in practice and we could just provide an async version of the write! macro instead.

Just checked the signatures and I think I'm mostly agreeing here tbh. The macro seems relatively straight forward too: https://doc.rust-lang.org/src/core/macros.rs.html#388-390.

Okay yeah I'm on board with not implementing async_std::fmt, and relying on std::fmt::Write instead. As for the specific implementation here: I think we should probably write some custom code for the implementation as std::fmt::Write doesn't seem to appear in any signatures.

@dignifiedquire how does this sound?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api design Open design questions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants