Skip to content
This repository was archived by the owner on Apr 5, 2021. It is now read-only.

Conversation

icefoxen
Copy link

@icefoxen icefoxen commented Apr 11, 2017

PR to make AppInfo a trait and have different structures with different ownership semantics for it. Resolves issue #19

I still think there should be some way to use Cow to make this simpler, but it's less ergonomic. Oh well.

icefoxen added 5 commits April 5, 2017 10:18
Maybe we can just make it an enum instead?  It'll break the API either
way, tbh, but I'm curious.
…thing.

This commit is just for reference, probably going to just do the simplest
way.
@daboross
Copy link

daboross commented Feb 14, 2018

If ergonomics for Cow are a blocker, do you think it could be fixed with a new method like this?

pub fn new<U, A>(name: U, author: T)
where
    U: Into<Cow<'static, str>>,
    A: Into<Cow<'static, str>>,
{
    AppInfo { name: name.into(), author: author.into() }
}

The pattern of accepting Into<Cow<str>> is one I've used a lot when I want to accept both String and &'static str in the same method. AppInfo::new("a", "b") and AppInfo::new("a".to_owned(), "b".to_owned()) should both work with this.


I realize this is an old PR which has been untouched; but if the trait design is why, it would be nice to fix it to have these improvements in the project.

@icefoxen
Copy link
Author

@daboross That does actually look pretty cool, I didn't think of that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants