-
Notifications
You must be signed in to change notification settings - Fork 3
io::Error should be usable without allocation #12
Comments
I'd prefer a plan like the one outlined here rust-lang/rfcs#2262 where we introduce IMO the big fat error types like |
rust-lang/rust#35121 fwiw if my |
Could the portability WG make an official-ish crate (or bless one of the existing ones) for that (Read/Write traits with associated types)? in the issue tracker of that crate / repo we could discuss whether we want to land them in the official core. I have wanted those traits before and I'd rather not create and maintain such crate. I'm pretty sure I've seen at least one crate that defines such traits on crates.io and I think I've also seen those traits defined in the std implementation of some OS thing (?). We should all agree on a single definition of those traits, IMO. |
There's core_io (https://crates.io/crates/core_io) but it's autogenerated at build time, which is not nice for vendoring. |
That crate does not have the Read / Write traits with associated Error types. It has a port of std::io::Error to core. |
@japaric Well of course I'd be happy to clean up my own https://github.com/QuiltOS/core-io and make it official /s. In seriousness I'd to first gather consensus we're on board experimenting with this (maybe with an eRFC), and then implement on a branch/fork in the actual repo. The finer-grained design details would be pend on what we discover during the implementation, as it's nigh impossible to predict without actually doing the work, and a waste of effort to expect an implementation first. |
@fluffysquirrels picking up from rust-lang/rfcs#2262 (comment)
I don't think the feature flag is so good because then every instance also needs the feature flag. For example, there are uses for these |
Optional dependencies and feature flags are very similar (cargo docs on features), so whichever is fine. If you have downstream dependencies that optionally use alloc/std, I think you may need feature flags to toggle their options. Last I looked importing alloc in a no_std crate actually required a crate attribute I have worked with no_std, no alloc crates for microcontrollers, and personally I found that feature flags are straightforward to use once you implement your first one and get used to the recipe:
|
Ahoj, taking this thread to 2019, I'm wondering where we are with this topic? Over on https://internals.rust-lang.org/t/idea-lowering-std-io-to-core/7341 I learned from rpjohnst that
This seems to be a move in a completely opposite direction. Do I get it right that as long as I'm not touching allocation requiring methods, I can work against std even without an allocator? Can someone shed a light on this? Is that already available? It sounds like dark magic to me. I'd like to produce a library without std dependency, but exposing Read / Write implementation for interoperability. I find the Err associated type more Rusty, but I cannot foresee the implications. Looking at QuiltOS/core-io I was surprised how simple it is. Such a simple thing doesn't probably require much maintenance. Perhaps it is time for a breaking change and Read2 / Write2? :D Or perhaps the more generic but less feature-rich Read2 / Write2 could be expanded on in std to deliver compatible features? |
Seems discussed a lot, what's the real blocker? |
To put the current situation in a nutshell after asking in various chats (please correct me if I'm wrong on anything):
Taking all of that together, we need a new error type for Considering these facts, is there any chance for stabilized CC'ing the Error Handling Project Group, which looks like the new place to handle this issue: rust-lang/project-error-handling#11 |
Uh oh!
There was an error while loading. Please reload this page.
In the mean time, see https://crates.io/crates/core_io
The text was updated successfully, but these errors were encountered: