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

Add Any type, use for task failure and Result #9881

Closed
brson opened this issue Oct 15, 2013 · 7 comments
Closed

Add Any type, use for task failure and Result #9881

brson opened this issue Oct 15, 2013 · 7 comments
Milestone

Comments

@brson
Copy link
Contributor

brson commented Oct 15, 2013

This needs further debate.

The most obvious use case for ~Any is for dealing with arbitrarily typed error values. Add it to std, use it for task failure.

Consider changing the Err variant of Result to take ~Any. This would allow monad-style error chaining to work much better since all Results have the same error type.

cc #61, #2408

@brson
Copy link
Contributor Author

brson commented Oct 15, 2013

Nominating.

@Kimundi
Copy link
Member

Kimundi commented Oct 16, 2013

For future reference, a possible implementation of ~Any can be seen here: https://gist.github.com/Kimundi/6802198

Right now it uses the Type descriptor pointer as a "Type ID", but for proper cross-crate support it needs a proper intrinsic for that.

Also, for a ~Any to be convenient, there needs to be a way to cast trait objects to other trait objects provided the boxed type implements both. At least upcasting should be supported.

Use case is, eg, for a &Any to be cast to &ToStr for enabling dynamic printing of their value, or in the case of inheritance allow casting a &AnyToStr with trait AnyToStr: Any+ToStr to &Any.

@brson
Copy link
Contributor Author

brson commented Oct 17, 2013

We might actually want a more specific dynamic ~Error for this use case.

@catamorphism
Copy link
Contributor

1.0, backcompat

@pnkfelix
Copy link
Member

(fixing this is part of our error-handling story, which in turn is related to #9795 )

@eddyb
Copy link
Member

eddyb commented Nov 8, 2013

I found it odd there is no mention of #9967 in here, is there any reason for that, or was it just overlooked?

@Kimundi
Copy link
Member

Kimundi commented Nov 8, 2013

Just overlooked, someone should close this issue.

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 21, 2022
Rustup

r? `@ghost`

It took >4 weeks, but I finally got to do the sync 🎉

changelog: none
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

No branches or pull requests

6 participants