Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Generator::lib_name and with_lib_name should take AsRef<str> instead of AsRef<String> #8

Open
ghost opened this issue Nov 3, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 3, 2020

Neither String or &String actually implement AsRef<String>. To work around that using standard types I had to wrap the string with a smart pointer: .lib_name(Box::new("mylibrary".to_string())).

@karroffel
Copy link
Member

Oh that's an oversight, thanks for reporting! 👍 I'll change it right away!

@karroffel
Copy link
Member

The type seems to be AsRef<str> which both String, &String and &str should implement, no?

/// Set the name of the crate.
pub fn with_lib_name(&mut self, name: impl AsRef<str>) {
let name = name.as_ref().to_string();
self.lib_name = Some(name);
}
/// Set the name of the crate.
pub fn lib_name(mut self, name: impl AsRef<str>) -> Self {
self.with_lib_name(name);
self
}

@karroffel
Copy link
Member

It seems like that's an issue on the latest crates.io version but the git version should work!

@ghost
Copy link
Author

ghost commented Nov 4, 2020

Yes, I was using the crates version. I'll switch to the git version for now. Sorry for not checking it first.

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

No branches or pull requests

1 participant