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

Into<Channel> should be a specific trait. e.g. AsChannel #45

Closed
museun opened this issue Jun 22, 2019 · 0 comments
Closed

Into<Channel> should be a specific trait. e.g. AsChannel #45

museun opened this issue Jun 22, 2019 · 0 comments

Comments

@museun
Copy link
Owner

museun commented Jun 22, 2019

This will allow for better coherence. The blanket Into from std lib for coherence breaks the current attempt.

Currently something like the following has problems:

struct S;
impl Display for S {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        write!(f, "foobar")
    }
}

fn foo(d: impl Into<Channel>) { 
    let ch = d.into();
}

foo("foobar"); // works
foo(S{}); // does not work
foo(S{}.to_string()); // works

And a bit of bikeshed. ToChannel vs AsChannel (e.g. consuming or borrowing). With the way the Writer works, it doesn't need ownership because its just going to format a string in the end, so everything can be borrowed which would be concatenated with some static data.

@museun museun closed this as completed in 30a765f Jun 22, 2019
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

1 participant