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

New defaults to bin #5029

Merged
merged 3 commits into from
Feb 13, 2018
Merged

New defaults to bin #5029

merged 3 commits into from
Feb 13, 2018

Conversation

matklad
Copy link
Member

@matklad matklad commented Feb 12, 2018

So this switches cargo new default from --lib to --bin, as discussed on IRC.

The first two commits are just refactorings, and the last one actually flips the switch. Surprisingly enough, no tests need to be modified it seems!

r? @withoutboats

@matklad matklad added the relnotes Release-note worthy label Feb 12, 2018
@ehuss
Copy link
Contributor

ehuss commented Feb 12, 2018

Will updating the Cargo book be done separately? It's not clear to me how that is published.

@matklad
Copy link
Member Author

matklad commented Feb 12, 2018

An excellent comment @ehuss!

I've updated the docs to mention both --bin and --lib. I think it's better to pass an explicit argument in the docs at least for some time, because there may be older Cargos in packages managers and such.

I am almost sure that this is not the only one place in the docs which needs to be updated though :(

Let's cc @steveklabnik just in case :)

@@ -7,7 +7,7 @@ $ cargo new hello_world --bin
```

We’re passing `--bin` because we’re making a binary program: if we
were making a library, we’d leave it off.
were making a library, we’d pass `--lib`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think src/doc/src/guide/creating-a-new-project.md also needs to be updated, since it talks about --bin in more detail.

@withoutboats
Copy link
Contributor

cc @rust-lang/cargo

Big +1 on this change, I'd like to get it in the same beta as the other change to cargo new, but I know we cut a beta soon so maybe the other change should be held back.

We should be very proactive about announcing this change. Not only do our docs need to change, we also need to inform other people who may be teaching Rust of the change to the default behavior, since they'll likely be walking people through this as a first step.

@withoutboats withoutboats self-requested a review February 13, 2018 10:24
@withoutboats
Copy link
Contributor

withoutboats commented Feb 13, 2018

@bors r+

2:50 AM <matklad> 6 weeks seem plenty to me for this change: it seems *much*
less troublesome than the recent CWD change, for example
2:50 AM <matklad> and reverting that `rust-` change to make sure it goes in the
same release as `new --bin` seems like a hassle :)  

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

📌 Commit 9cb10e6 has been approved by withoutboats

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

⌛ Testing commit 9cb10e6 with merge 1780cdf6436f1567bbb90cb9337b6af73643dba3...

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

💡 This pull request was already approved, no need to approve it again.

  • This pull request is currently being tested. If there's no response from the continuous integration service, you may use retry to trigger a build again.

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

📌 Commit 9cb10e6 has been approved by withoutboats

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

⌛ Testing commit 9cb10e6 with merge 7320c305e981f24e7fa3cb2d07ce58358256ca8d...

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

💡 This pull request was already approved, no need to approve it again.

  • This pull request is currently being tested. If there's no response from the continuous integration service, you may use retry to trigger a build again.

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

📌 Commit 9cb10e6 has been approved by withoutboats

@bors
Copy link
Collaborator

bors commented Feb 13, 2018

⌛ Testing commit 9cb10e6 with merge 5891aec...

bors added a commit that referenced this pull request Feb 13, 2018
New defaults to bin

So this switches `cargo new` default from `--lib` to `--bin`, as discussed on IRC.

The first two commits are just refactorings, and the last one actually flips the switch. Surprisingly enough, no tests need to be modified it seems!

r? @withoutboats
@bors
Copy link
Collaborator

bors commented Feb 13, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: withoutboats
Pushing 5891aec to master...

@bors bors merged commit 9cb10e6 into rust-lang:master Feb 13, 2018
@matklad matklad deleted the new-defaults-to-bin branch February 13, 2018 11:47
@pwoolcoc
Copy link
Contributor

@matklad got here from TWIR, I was wondering if the reasoning was recorded anywhere other than IRC? I'm just curious what the reasoning was.

@matklad
Copy link
Member Author

matklad commented Feb 21, 2018

@pwoolcoc sure, #5013 (comment) I believe is the most recent discussion (it includes the link to urlo post as well).

The TL;DR is

  • new users want --bin for hello world.
  • some old users (for example @matklad) create a dozen of crates per day just for experimentation, and for experiments --bin makes more sense.

@pwoolcoc
Copy link
Contributor

@matklad thanks!

@ramn
Copy link

ramn commented Feb 25, 2018

What do you think about allowing cargo bin and cargo lib? Silly proof of concept: https://crates.io/crates/cargo-bin-lib

You know what you will get and with less typing to boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Release-note worthy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants