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 type-driven generic data access to std #1

Closed
wants to merge 1 commit into from
Closed

Add type-driven generic data access to std #1

wants to merge 1 commit into from

Conversation

nrc
Copy link
Owner

@nrc nrc commented Aug 27, 2021

This RFC proposes adding a provide_any module to the core library. The module provides a generic API for objects to provide type-based access to data. (Whereas the any module provides type-driven downcasting, the proposed module integrates the downcasting into data access to provide a safer and more ergonomic API).

By using the proposed API, an object can have functionality like:

let s: String = object.request();
let s = object.request_field::<str>(); // s: &str
let x = object.request_field::<SpecificContext>(); // x: &SpecificContext

text/0000-dyno.md Outdated Show resolved Hide resolved
text/0000-dyno.md Show resolved Hide resolved
text/0000-dyno.md Outdated Show resolved Hide resolved
text/0000-dyno.md Outdated Show resolved Hide resolved
text/0000-dyno.md Outdated Show resolved Hide resolved
text/0000-dyno.md Show resolved Hide resolved
text/0000-dyno.md Show resolved Hide resolved
zkat added a commit to zkat/miette that referenced this pull request Sep 5, 2021
This PR overhauls the toplevel/main experience for `miette`. It adds a new `Report` type based on `eyre::Report` and overhauls various types to fit into this model, as well as prepare for some [future changes in Rust](nrc/rfcs#1) that will make it possible to integrate `miette` directly with crates like `eyre` instead of having to use this specific `Report`.

As such, this PR is a major breaking change, especially for anyone using `DiagnosticReport` and company.

BREAKING CHANGES:
* `DiagnosticReport` is now just `Report`, and is a different, `eyre::Report`-like type.
* `DiagnosticResult` is now just `Result`.
* `.into_diagnostic()` now just transforms the error into a `Report`.
* `DiagnosticReportPrinter` has been replaced with `ReportHandler`
* `set_printer` has been replaced by `set_hook`
* `code` is now optional.
* `.into_diagnostic()` no longer takes a `code` argument.
* `#[diagnostic]` is now optional when deriving `Diagnostic`.
Signed-off-by: Nick Cameron <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants