Skip to content

Change some APIs for downstream crate implementors #86

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

Draft
wants to merge 2 commits into
base: main-dev
Choose a base branch
from

Conversation

SpriteOvO
Copy link
Owner

@SpriteOvO SpriteOvO commented Apr 8, 2025

Currently, I'm working on a separated crate spdlog-telegram which writes log records to a Telegram chat, and I found some API is hard (even impossible) to use from a downstream crate implementor in the ecosystem.

This PR improves some APIs to solve such problems (with API breaking changes, of course), aiming not just to make crate spdlog-telegram, but more downstream crates could be easily developed in the ecosystem.

I will update more details to explain each commit changes later.

@SpriteOvO SpriteOvO added this to the v0.5.0 milestone Apr 8, 2025
@SpriteOvO SpriteOvO force-pushed the improve-for-downstream branch from 1d5cf9a to 962f521 Compare April 12, 2025 16:01
@SpriteOvO
Copy link
Owner Author

SpriteOvO commented Apr 12, 2025

As a first thought, I was tried to omit the explicit ErrorHandler::new calling by accepting a generic type F where F has Into<fn> impl if user is passing a closure as a argument to {,set_}error_handler methods.

However, it doesn't work. It is surprised that there is no such an auto implementation:

fn foo(_: fn()) {}
fn bar<F: Into<fn()>>(_: F) {}

fn main() {
    foo(|| {}); // OK
    bar(|| {}); // Error
    bar::<fn()>(|| {}); // OK
}

I did ask about it on Zulip (link), it may be an opportunity to contribute to Rust stdlib.

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.

1 participant