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

Improve initialization in workspace #2076

Merged
merged 2 commits into from
Aug 8, 2024
Merged

Conversation

senekor
Copy link
Contributor

@senekor senekor commented Aug 8, 2024

  • Detect if we are in a cargo project more reliably. (e.g. if rustlings init is run in the src/ directory)

  • Refuse to initialize rustlings in a non-workspace cargo project.

  • Automatically populate the workspace.members field if rustlings init is run in a workspace.

    This may be considered risky, as there is no guarantee that's what the user wanted to do. However, it is consistent with the behavior of cargo new. Also, newcomers to Rust are unlikely to accidentally be in a cargo workspace, as they won't know how to create one in the first place.

    The use case for initialization in a workspace is when a workshop organizer wants to use rustlings alongside other exerices and provide a single repository with everything in one place.

senekor added 2 commits August 8, 2024 13:34
- Detect if we are in a cargo project more reliably.
  (e.g. if `rustlings init` is run in the `src/` directory)

- Refuse to initialize rustlings in a non-workspace cargo project.

- Automatically populate the `workspace.members` field if `rustlings init` is
  run in a workspace.

  This may be considered risky, as there is no guarantee that's what the user
  wanted to do. However, it is consistent with the behavior of `cargo new`.
  Also, newcomers to Rust are unlikely to accidentally be in a cargo workspace,
  as they won't know how to create one in the first place.

  The use case for initialization in a workspace is when a workshop organizer
  wants to use rustlings alongside other exerices and provide a single
  repository with everything in one place.
@mo8it
Copy link
Contributor

mo8it commented Aug 8, 2024

Thanks! I will merge and improve some things in a commit :)

@mo8it mo8it merged commit 9f9a754 into rust-lang:main Aug 8, 2024
7 checks passed
@mo8it
Copy link
Contributor

mo8it commented Aug 8, 2024

My improvements: 140c4e4

@senekor
Copy link
Contributor Author

senekor commented Aug 8, 2024

Nice!

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

Successfully merging this pull request may close these issues.

2 participants