-
Notifications
You must be signed in to change notification settings - Fork 78
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
Use bin
target name instead of package name as default
#157
Conversation
if let Some(target) = package | ||
.targets | ||
.iter() | ||
.find(|target| target.kind.iter().any(|k| k == "bin")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be target.kind.contains("bin")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It causes a compile error because the iterated item is &String
(target.kind
is Vec<String>
). target.kind.contains(&"bin".to_string())
works, but it causes redundant heap allocation.
error[E0308]: mismatched types
--> src/bundle/settings.rs:155:57
|
155 | .find(|target| target.kind.contains("bin"))
| -------- ^^^^^ expected `&String`, found `&str`
| |
| arguments to this method are incorrect
|
= note: expected reference `&std::string::String`
found reference `&'static str`
note: method defined here
--> /Users/rhysd/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/slice/mod.rs:2509:12
|
2509 | pub fn contains(&self, x: &T) -> bool
| ^^^^^^^^
For more information about this error, try `rustc --explain E0308`.
error: could not compile `cargo-bundle` (bin "cargo-bundle") due to previous error
* `name`: The name of the built application. If this is not present, then it will use the `name` value from | ||
your `Cargo.toml` file. | ||
* `name`: The name of the built application. If this is not present, then it will use the `name` value from `bin` | ||
target in your `Cargo.toml` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which bin
does it choose if there is more than one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First one is chosen. My understanding is that multiple bin
targets are not supported. Shall I explicitly note it here?
Fixes #156