-
Notifications
You must be signed in to change notification settings - Fork 61
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
How can we better support no-std usecases? #85
Comments
I think sticking a |
Without implementing |
An error enum with conversions, possibly backtrackes (?) and optional no_std compat, I guess. |
Are you interested in using SNAFU in a no-std environment? If so, which aspects are you looking for?
I don't think this is possible as
Isn't that what we are talking about? To put it another way, every crate could have a no-std mode. In the worst case, everything in the crate would be disabled. I hope you'd agree that such a switch would not be useful, however. That's what I'm trying to determine — what is the usefulness of SNAFU when it doesn't have access to the standard library? |
No, not right now. I've published an optional no-std crate, but I used a hand-written enum for it. I didn't consider
Ah, okay. I was on my phone and couldn't check.
The crate I mentioned earlier has optional std support for two things:
Having the conversions might be enough for some. If people are using |
What interface does that enum present to the user who consumes it? How do they make use of an error type that doesn't implement
This is a benefit to the library author, certainly, and I can see how it might be nice.
Sure, which is why I opened this issue in the first place, but I don't yet understand the benefits of using either Failure or SNAFU in a no-std crate. |
Thank you for this conversation, by the way! |
As somebody who recently started migrating from |
I’m open to having this happen. As I understand it, the plan basically needs to be:
|
FWIW: backtrace-rs could in theory be no_std and in fact std is an optional feature, although I suspect all current backends require std (maybe the goblin/addr2line backend doesn't ?) I am personally working on a project (custom OS) that will eventually involve a no_std backtrace implementation. At that point, snafu will make a lot of sense for me for error handling as it provides:
|
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to snafu. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, snafu now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. Resolves shepmaster#85
This brings no_std support to SNAFU. It now has a `std` feature which is activated by default. To make no_std support as frictionless as possible, SNAFU now reexports the `std::error::Error` trait as `snafu::Error` when the feature is activated and defines its own API compatible trait instead when it's disabled. In order to not commit to having a publicly visible copy of the `Error` trait in SNAFU, hiding it from the documentation allows for SNAFU to still support all of its features, but the user never gets to use the trait. This way SNAFU can switch out the trait at any point with `core::error::Error` if that becomes a thing. Alternatively the trait here can also be made visible at some point. Both of these possibilities are not breaking, so the conservative approach with `doc(hidden)` allows for the smoothest experience going forward. Resolves shepmaster#85
Originally, SNAFU was going to support no-std, until I learned that the
Error
trait doesn't exist in libcore!That being said, people have said that failure works will in no-std. Evidently, failure can just implement
Display
in this case.We certainly could do the same, but I wonder if there's some other powers we could add. My wildest thought would be to establish a parallel
Error
trait that we could implement instead of (or in addition to?)std::error::Error
.Would this be something that
ErrorCompat
should do?The text was updated successfully, but these errors were encountered: